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
Regression transformation with ln and squared values Hello, I assume a nonlinear relationship between TobinsQ and sumholdingpct. Is it then appropriat…
Plot the prediction the native-migrant LFP at the 25th and 75th percentile of an explanatory varibleHello, I trying to generate a plot that has the YSM on the x-axis and the native-migrants LFP differ…
code for classifying participants based on complex criteria on a 9-item scaleI'm looking for code to classify participants with depression using more complicated diagnostic crit…
Automating the process of copying and pasting in STATAHi, I am trying to copy and paste the first 20 observation onto a new column but the values start a…
Avoid duplicate removal: Loop to create new id of a duplicate within panel?Dear Statalist Community, I have a problem with repeated time values in my panel (daily time interv…
Subscribe to:
Post Comments (Atom)
0 Response to Error with levelsof but not levels command
Post a Comment