Hi everyone,
Has anyone experienced errors with levelsof not present with levels commands? This curious case occurs with the following effort to find the value for _n at which rho is maximized or MAE is minimized under specific conditions. The `variables' list has "ihap irlx isad" and `panelrange' is "1/3". The following levels command works:
if "`Ecriterion'"=="rho" | "`Ecriterion'"=="mae" {
qui gen long obsno=_n
foreach var of varlist `variables' {
foreach id of numlist `panelrange' {
capture noisily {
quietly summarize SP_`Ecriterion'_`var'_ID if SP_id_`var'_ID==`id' & SP_d_`var'_ID==`diff', meanonly
if "`Ecriterion'"=="rho" loc a="max"
else if "`Ecriterion'"=="mae" loc a="min"
levels obsno if SP_`Ecriterion'_`var'_ID == r(`a') & SP_id_`var'_ID==`id' & SP_d_`var'_ID==`diff'
loc emax`var'`id'=SP_e_`var'_ID[`r(levels)']
}
}
}
}
The code is not perfect and could use a clean, but it works just fine. I have confirmed this by checking the contents of the `emax`var'`id'' macros. However, curiously, if the "levels" command is replaced with "levelsof", then the following errors result:
SP_e_ihap_ID not found
SP_e_ihap_ID not found
SP_e_ihap_ID not found
SP_e_irlx_ID not found
SP_e_irlx_ID not found
SP_e_irlx_ID not found
SP_e_isad_ID not found
SP_e_isad_ID not found
SP_e_isad_ID not found
This is very strange, I think, because the two commands are often interchangeable (and meant to be so)? If anyone has experienced anything similar or can diagnose the problem, please let me know! The gtools version of levelsof also produces the same errors.
Thanks for any input and time you can offer!
Mike
Related Posts with Error with levelsof but not levels command
Understand group differences with Likert item dependent and independent variableHi, I'd like to understand what may drive differences in my dependent variable between two sub-popu…
Reference Country (for industries)Dear all, Thank you so much for all your help! In the data below, I want to compare the value added…
Summing observations that fall below a scoreI am hitting a wall trying to create a variable that is a conditional sum where it looks at the scor…
Panel data error due to several companies inside countryI am currently writing my master thesis and need to check how percentages of females on the manageme…
Log TransformationHello, Should you ever log transform ordinal data? Or can you only log transform continuous variabl…
Subscribe to:
Post Comments (Atom)
0 Response to Error with levelsof but not levels command
Post a Comment