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
Autocorrelation Parameter Estimates ≥ 1 in SP Stata ManualI noticed a 3 examples in the Spatial Autoregressive Models Reference Manual (Release 16) that 3 exa…
Creating country specific linear and quadratic time trendsHi everyone, I was trying to include linear and quadratic id specific time trends in my model (sepa…
Creating a new variable, from specific values of 3 existing variablesHello, I am really bad in stata and need help. I have a database with 3 variables: birthcountry, aut…
Is Poisson the correct model here? I have data on a company who instituted a feature where they stop promoting items listed after X ho…
How to calculate the standard deviation and the average per sector? Hello everyone! I need to calculate the value of the (1) standard deviation and the (2) average (bo…
Subscribe to:
Post Comments (Atom)
0 Response to Defining variables in a loop
Post a Comment