Hi all,
I'm trying to run the following loop:
foreach country in country_list {
use "D:\...\estimation"
keep if COUNTRY==`country'
save "D:\...\estimation_`country', replace
foreach code in code_list {
use "D:\...\estimation_`country'"
capture keep if CODE==`code'
xtile dec_var=var, n(10)
gen var_10=var if dec_var==1
collapse (mean) var_10, by(CODE13) *CODE13 is another variable in the subset
graph bar var_10, over(CODE13)
}
}
However, since not every country has all the CODEs in code_list, when I run it I obtain the following error as soon as the variable in code list is not there:
"nquantiles() must be less than or equal to number of observations plus one"
How can I solve this issue?
Thanks in advance
I'm trying to run the following loop:
foreach country in country_list {
use "D:\...\estimation"
keep if COUNTRY==`country'
save "D:\...\estimation_`country', replace
foreach code in code_list {
use "D:\...\estimation_`country'"
capture keep if CODE==`code'
xtile dec_var=var, n(10)
gen var_10=var if dec_var==1
collapse (mean) var_10, by(CODE13) *CODE13 is another variable in the subset
graph bar var_10, over(CODE13)
}
}
However, since not every country has all the CODEs in code_list, when I run it I obtain the following error as soon as the variable in code list is not there:
"nquantiles() must be less than or equal to number of observations plus one"
How can I solve this issue?
Thanks in advance
Comment