I will guess that your yeargroup variable takes values from 1 to 12. So when you adapted my code to match your data, where I wrote
which corresponded to the two values that the variable smsa could take in the example data I used to demonstrate the process (lacking any example of your data), why did you change it to
instead of
which would correspond to the values that the variable yeargroup takes in your data?
Of course, that was a guess. Perhaps yeargroup takes some entirely different set of values; you have not said what values it takes. The important thing is that to have the set of regressions run separately for each value of yeargroup the for command you use to construct the loop (forvalues in this case) has to include what those values actually are. The first time through the loop the keep command became
and no observations were kept.
Code:
forvalues sm = 0/1 {
Code:
forvalues sm = 0/12{
Code:
forvalues sm = 1/12 {
Of course, that was a guess. Perhaps yeargroup takes some entirely different set of values; you have not said what values it takes. The important thing is that to have the set of regressions run separately for each value of yeargroup the for command you use to construct the loop (forvalues in this case) has to include what those values actually are. The first time through the loop the keep command became
Code:
keep if yeargroup==0
Comment