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
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
Comment