I have a list of variables that I want to loop through:
yr2008_q110atte
yr2009_q112atte
yr2010_q112atte
yr2011_q110atte
yr2012_q110atte
As you can see, they all start with "yr" and ends with "atte", although the question number in each year is different.
So, I write the loop below:
foreach i in 2008 2009 2010 2011 2012{
tab yr`i'_*atte yr`i'_age_grp
gen yr`i'_atte = . if yr`i'*atte == 1
gen yr`i'_atte = 1 if yr`i'*atte == 1
replace yr`i'_atte = 0 if yr`i'*atte == 1
}
The first line of tabulating variables works, but starting from the second line within the loop, the yr`i'*atte condition doesn't work, as stata returns "yr2008 ambiguous abbreviation".
Any clue on how to resolve this? Thank you!
Related Posts with loop variables with * wildcard
how to do fixed effects regressionHey my regression does not work, how do I do a fund and time fixed effectes regression? What do I ha…
Interpretation of ARCH/GARCH coefficientsHello! I need some help on interpreting the ARCH and GARCH terms of this regression output. The var…
How to model persistence using survival analysis techniquesDear members, I am trying to model persistence in exporting on a sample of new firms using survival…
How to keep ONLY individuals who respond every year in a household panel dataHello everyone, I am new to Stata and as a part of my bachelor thesis, I have to do a fixed effect …
Splitting YearDear, I am quite new to STATA and I need t seprate the year from tthe months and days, i.e. right no…
Subscribe to:
Post Comments (Atom)
0 Response to loop variables with * wildcard
Post a Comment