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
A question about computing margins for xtmelogitI am using xtmelogit in Stata 15.1 to analyze a dataset that is nested in schools. I used the code b…
Integer related issueI'm new to STATA. I used Excel prior but recently purchased STATA. I'm learning as I go. Here is my …
Mixed Design ANCOVAHi guys, I am having difficulties with choosing an appropriate statistical analysis for my research…
Choice model (cm) data layoutHi all, I am in the midst of setting up my data to run a panel-data mixed logit choice model (cmxtm…
Calculating proportions of the make-up of different program groups at different measurement occasions - helpHello, My dataset consists of ~6000 referrals to a suite of four types of psychological programs ov…
Subscribe to:
Post Comments (Atom)
0 Response to Defining variables in a loop
Post a Comment