Originally posted by Andrew Musau
View Post
How could I do what you proposed? I tried (see the commands in bold):
Code:
local predictors_all_moms c.mom_age c.mom_age#c.mom_age c.mom_age_at_birth i.mom_edattain2 i.mom_edattain3 i.mom_edattain4 i.mom_child_loss_categorical i.mom_cohort local predictors_married_moms c.mom_age c.mom_age#c.mom_age c.mom_age_at_birth c.pop_age c.pop_age#c.pop_age i.mom_edattain2 i.mom_edattain3 i.mom_edattain4 i.pop_edattain2 i.pop_edattain3 i.pop_edattain4 i.mom_cohort i.mom_child_loss_categorical levelsof sample, local(samples) local sample_labels: value label sample frame create results frame results{ set obs `=wordcount("`samples'")' gen sample=. gen all=. gen married=. } local i 0 foreach sample of local samples{ local ++i local vl: label `sample_labels' `sample' regress mom_fertility i.FirstDaughter `predictors_all_moms' if `sample'== sample [pweight=mom_perwt] frame results: replace sample= `vl' in `i' (instead of frame results: replace sample= `sample' in `i') frame results: replace all= `=_b[1.FirstDaughter]' in `i' regress mom_fertility i.FirstDaughter `predictors_married_moms' if `sample'== sample [pweight=mom_perwt] frame results: replace married= `=_b[1.FirstDaughter]' in `i' } frame change results export excel using myfile, replace firstrow(variables)
Comment