I have smallholder agriculture plot level commercialization data which i want to collapse to household level data. To avoid losing variable labels i resorted to the foreach loop method below by Cox;
Copy variable labels before collapse . foreach v of var * { . local l`v' : variable label `v' . if `"`l`v''"' == "" { . local l`v' "`v'" . } . } Attach the saved labels after collapse . foreach v of var * { . label var `v' "`l`v''" . }
Whenever i try running this codes, i am getting the error message:
"foreach command may not result from a macro expansion interactively or in do files"
What could be the reason? Thank you in advance
Takesure Tozooneyi
Related Posts with How to avoid losing variable labels when using collapse command
Collinearity among multiple category IVs in survey dataHi folks, Insights please! I am running logit model with complex survey data. All the independent …
sfpanel postestimationDear Stata Users, I'm trying to estimate technical efficiency with -sfpanel post estimation command…
Problem with predicting survival probabilities from stpm2 model with TVC in external dataI have built a prognostic model using stpm2 which includes a tvc (all covariates in model are center…
Using r() with recodeI am trying to recode a variable using the values from the return list but from the error message I …
command for conditional likelihood regression using timesseries dataDear mr/mrs, I am currently trying to make a regression in STATA using times-series data on GNP. I …
Subscribe to:
Post Comments (Atom)
0 Response to How to avoid losing variable labels when using collapse command
Post a Comment