Hi guys,
I am quite new to Stata and I can't find a solution to the following problem:
I am working with individual level survey data. I have generated many new variables in this dataset such as (mean wage for low-skill people, mean wage for high-skill people, mean hours worked for low- skilled people etc.) for each year and region.
For further analysis I would like to create a new frame where for each variable (e.g. low-skill wage) I pick the mean value for each region and year.
So, actually I want to create a Panel Dataset with mean values from the individual dataset by region and year.
My code so far looks as follows:
frame create resultsregion region year ls1_L ls1_ln ls1_lf ls1_M ls1_mn ls1_mf ls1_H ls1_hn ls1_hf ls2_L ls2_ln ls2_lf ls2_M ls2_mn ls2_mf ls2_H ls2_hn ls2_hf rrhwage_L rrhwage_ln rrhwage_lf rrhwage_M rrhwage_mn rrhwage_mf rrhwage_H rrhwage_hn rrhwage_hf
frame post (mean(region)) (mean(year)) (mean(ls1_L)) (mean(ls1_ln)) (mean(ls1_lf)) (mean(ls1_M)) (mean(ls1_mn)) (mean(ls1_mf) (mean(ls1_H)) (mean(ls1_hn)) (mean(ls1_hf)) (mean(ls2_L)) (mean(ls2_ln)) (mean(ls2_lf)) (mean(ls2_M)) (mean(ls2_mn)) (mean(ls2_mf)) (mean(ls2_H)) (mean(ls2_hn)) (mean(ls2_hf)) (mean(rrhwage_L)) (mean(rrhwage_ln)) (mean(rrhwage_lf)) (mean(rrhwage_M)) (mean(rrhwage_mn)) (mean(rrhwage_mf)) (mean(rrhwage_H)) (mean(rrhwage_hn)) (mean(rrhwage_hf))
I think I should use a foreach loop with the frame post command but I have no idea how to specify it.
Thank you for your help.
Kind regards,
Leandro
Related Posts with Building a panel dataset from individual level data using loops
Unbalanced Panel - Selection Bias due to unequal time periods onlyHi everyone, I have an unbalanced panel data per Stata as seen here: Code: . //Setting panel var…
Divide the string including chinese into two columnsdear sir: I want to know how to divide the following strings into two columns, one for Chinese chara…
Panel data regression - problems getting reasonable results on debt ratioHi everyone, I'm running a regression on my panel data, where the results I'm getting on my debt ra…
IV-panel-xtivreg: zero coefficient; time fixed effectsHello Statalist! I'm doing the project about UIP(uncovered interest rate parity) and illiquidity ris…
repeating iterations with unchanging log likelihood valuesGreetings all, I am using meqrlogit to predict binary outcome (use of potentially harmful medicatio…
Subscribe to:
Post Comments (Atom)
0 Response to Building a panel dataset from individual level data using loops
Post a Comment