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
Omitted Dummy Variable on -spxtregress-Hello, I think I have a problem identifying issue after running random-effect panel data regression …
Plot confidence interval for medianI'd appreciate if anyone could help me with this one. I need to plot median and percentile confidenc…
Problem with Multiple ImputationHi all, I am (seemingly) having some trouble with my imputation model. I am trying to impute values …
Seasonally adjusted GDPI guess this is a simple question. How to get the seasonally adjusted GDP continuously compounded g…
How to filter data using keywordsHi everyone, I am a novice user of STATA. I have collected execucomp data on excel, where manager d…
Subscribe to:
Post Comments (Atom)
0 Response to How to avoid losing variable labels when using collapse command
Post a Comment