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, countrynumber
sort d10_`var'
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
4. sort d10_`var'
5. scalar p50d`var' = `r(p50)'
6. scalar p75d`var' = `r(p75)'
7. }
not sorted
r(5);
end of do-file
r(5);
my variables are ranked from 1950 to 2015 with missing data. Even when I 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, countrynumber
sort d10_`var'
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
4. sort d10_`var'
5. scalar p50d`var' = `r(p50)'
6. scalar p75d`var' = `r(p75)'
7. }
not sorted
r(5);
end of do-file
r(5);
my variables are ranked from 1950 to 2015 with missing data. Even when I 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