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
To transform cross-section data to panel dataDear Sir/Madam, I am doing the research on commercial jet aircraft, and each sample has "lease star…
Storing coefficients when running same regression for different sampleDear Statalisters; I need to run the same regression for 5000 different samples. I have a separate …
Panel data gaps and minimum number of observationsDear Statalisters, I am currently working on my Master Thesis and thus I analyze company financials…
rlaplace(m,b) command not workingHi, I would like to generate a random variable according to the laplace distribution. The command '…
append 65.000 .csv filesI have 8 folders and in every forlder I have 35042 .csv files. I would like to import and append al…
Subscribe to:
Post Comments (Atom)
0 Response to Building a panel dataset from individual level data using loops
Post a Comment