I just want to compute descriptive statistics of the categorical time-invariant variables in the attached longitudinal data file.
For the sake of efficiency, I used the following for-loop code to compute them.
However, something is wrong and I couldn't find what places are incorrect.
Thanks for your suggestions and help!
use data.dta,clear
local a male esl_pgm bil_pgm everspec hispanic
foreach var of a {
preserve
bys id: keep if _n==1
sum `var'
restore
}
Related Posts with Why is My Stata for-loop Code Wrong?
Country-Specific time trends in a fixed effects modelDear all, I am running a two-way fixed effects regression: Code: xtreg rate fertility unemp yout…
Interpreting P values in Sqreg versus QregHello, I am trying to understand how to interpret the p values I get after using sqreg versus qreg.…
Skillings Mack test?Hello all, I have a dataset of 25 participants who were sampled at 3 time-points (pre-intervention,…
Mediation analysis with -gsem-Dear all, I am doing a mediation analysis with -gsem- in Stata 15. The sem model includes models tha…
Plotting only a part of a map (such as a plotregion, or defined by x-y) using -spmap- or the graph editorHello everyone. This time I am involved in producing maps through spmap. I've had no major problems…
Subscribe to:
Post Comments (Atom)
0 Response to Why is My Stata for-loop Code Wrong?
Post a Comment