Hello All,
I have a long list of variables that all need to be defined in the same way.
I wrote the following which simply returns the error "invalid syntax".
The code works when I run with the lab val but without the lab def, suggesting a problem with the label define portion.
Advice please!
local varname "esttype_br_rural esttype_br_total esttype_br_urban [..rest of varnames.]"
local a=wordcount("`varname'")
forval i=1/`a'{
local name=word("`varname'", `i')
lab val `varname' `varname'_lab
lab def `varname'_lab ///
1 "Annual estimate" ///
3 "Three year moving average" ///
5 "Five year estimate" ///
10 "Ten year census"
}
Related Posts with Defining variables in a loop
Using the foreach/forval commands for different categories of a categorical variableI have a panel dataset with the following key variables: race, wealth, year. Race is a string variab…
Mixed effects Panel Data modelwhen to know when to use mixed effects panel data model in stata? …
Sort panel data according to country and yearHello, I want to generate a dummy variable which takes the value of 1 if the variable "Score" is bi…
combining commands to keep and drop certain observationsI would be grateful for advice on whether I need to execute the commands step by step (in what seque…
How to interpret results of regression with Box Cox transformed YHi everyone, Could please share your opinion on how should I interpret and explain the results of t…
Subscribe to:
Post Comments (Atom)
0 Response to Defining variables in a loop
Post a Comment