Hi dear member,
I am a beginner in the use of foreach. I need help to execute this code:
foreach var in eyrs_mf nostu_mf asr_mf {
gen d10_`var' = `var' - L10.`var'
su d10_`var' if year==2015, detail
scalar p50d`var' = r(p50)
scalar p75d`var' = r(p75)
}
When I execute the code above, I get the following error message:
. foreach var in eyrs_mf nostu_mf asr_mf {
2. gen d10_`var' = `var' - L10.`var'
3. su d10_`var' if year==2015, countrynumber
5. scalar p50d`var' = r(p50)
6. scalar p75d`var' = r(p75)
7. }
not sorted
r(5);
end of do-file
r(5);
I tell myself that the problem is located in this code «gen d10_`var' = `var' - L10.`var». My variables are ranked from 1950 to 2015 with missing data. I used a panel data. Even when I used xtset and try to sort using "bysort countrynumber eyrs_mf nostu_mf asr_mf: list wbcode" I always get the same error message. Thanks for your help
Related Posts with Problem with foreach
Relative risk and the risk differenceHi, I try to estimate the treatment effect in an RCT using the xtlogit command as I have panel data.…
Latent Class AnalysisHi Statalist I am performing Latent Class Analysis in STATA 14. I am using the following Code: gse…
iv with interactionI have an endogenous variable P . In my specification I also have interaction of P with X (X is an e…
Delete whole rowI have discovered that I have duplicates for a whole row (same person).. how do I delete the rows wi…
How to use -graph combine- and typical twoway options with -meta forest-Dear all, I would like to present forest plots side by side, but -meta forest- does not work well w…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with foreach
Post a Comment