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
Generating a variable based on other variableDear Profs and colleagues, I am going to generate a variable that shows how many export varieties f…
Fixed Effects on countries and dummy omittedHi all, I'm currently working on my master thesis on corporate bond spreads based on commodity pric…
Repeated measures with informative censoring time / competing eventHello all, This isn't necessarily a Stata-specific question, but more of a general statistical ques…
Ordered logistic regression with panel data and an interaction term between two binary independent variablesHi Users, I have a panel data set covering the years 2011-18 but mainly focusing on 2015-16. I am a…
Why are my variables being omitted by Stata?I'm doing a random effects model. I have a dummy per treatment, which would be "Message", "MessageTa…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with foreach
Post a Comment