Operation within Groups in Stata (bysort) | Data Management | Stata Tutorials Topic 33
HTML-код
- Опубликовано: 21 авг 2024
- Stata Tutorials Topic 33: Operation within Groups in Stata (bysort) | Summary Statistics and Data Management Using Stata
Hi, I am Bob. Welcome back to the Stata course on summary statistics and regression analysis. We will have a look at how to manage data within groups today. Sometimes, we need to get information from different groups of individuals. For example, we may want to know the average wage for male and female workers. That is, to get the average wage for each gender group. Or, we may want to figure out the minimum or maximum wage for each age group. To do that, we use the "bysort" prefix.
Please download the BOB.dta dataset:
drive.google.c...
The Stata commands in this video:
*load the course data BOB.dta
use BOB.dta, clear
describe
summarize
*within-group mean, min, and max
tabulate health
tabulate health, nolabel
bysort health: summarize hwage
bysort health: egen wage_group_mean=mean(hwage)
browse health hwage wage_group_mean
bysort health: egen wage_group_min=min(hwage)
bysort health: egen wage_group_max=max(hwage)
* _n and _N
list hwage in 1/10
display hwage[1]
display hwage[10]
display hwage[_N]
generate hwage2=hwage[_n-1]
list hwage hwage2 in 1/10
*bysort with _n and _N
bysort health: generate id=_n
bysort health: generate total=_N
browse health id total
【Some Free Courses on my RUclips Channel】
Economics in Real Life:
• Economics in Real Life
Solutions to Introductory Econometrics A Modern Approach 7th Edition:
• Solutions to Introduct...
Solutions to Microeconomics Theory and Applications with Calculus:
• Solutions to Microecon...
Introductory Stata:
• Introductory Stata (2022)
Introductory Microeconomics:
• Introductory Microecon...
Five Minute Econometrics:
• Five Minute Econometri...
Five Minute Stata:
• Stata Tutorials
【國語Mandarin】現實生活中的經濟學:
• 【Mandarin國語】現實生活中的經濟學
【粵語Cantonese】現實生活中的經濟學:
• 【Cantonese粵語】現實生活中的經濟學
【粵語Cantonese】微觀經濟學基礎:
• 粵語Cantonese微觀經濟學基礎2022
【國語Mandarin】五分鐘計量經濟學:
• 【Mandarin國語】五分鐘計量經濟學(計...
【粵語Cantonese】五分鐘計量經濟學:
• 【Cantonese粵語】五分鐘計量經濟學(...
On the Road:
• On the Road
【Become a Supporter of the channel ($2.99) to get PDF transcripts for】
1. Solutions to Microeconomics Theory and Applications with Calculus 5th Edition,
2. Solutions to Introductory Econometrics A Modern Approach 7th Edition,
3. Introductory Stata (2022), and
4. Introductory Microeconomics (2022).
/ @bobwenecon
#Stata #bysort #_n #_N #SummaryStatistics #DataManagement #withingroup #tutorial