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?
Importing Excel variables into Stata with shortened namesDear all, I am working with a dataset that contains information about individuals and their relatio…
Does this situation require a reshape long, or something different?Dear Statalisters, I would like to efficiently convert the following data: Code: * Example genera…
ADF TEST- drift, trend and constantHi everyone, I am a beginner when it comes to STATA, and I currently carrying out a time-series ana…
Extracting numbers from a string variable to put into a new variableHello, A few of my colleagues reviewed police investigative case files and measured the victims' de…
Problems with table command in Stata17I have some problems using table command in Stata 17 Code: webuse nhanes2l table (sex race) () () …
Subscribe to:
Post Comments (Atom)
0 Response to Why is My Stata for-loop Code Wrong?
Post a Comment