dimanche 6 janvier 2019

STATA: Count if multiple conditions met in varlist

I'm pretty new to both stata and data analysis so please forgive me for any language/technical errors. I've researched the following question endlessly to no avail.

I'm trying to count values of many string variables (hh_1_age hh_2_age hh_3_age etc.) based on multiple conditions, and send output to a new variable 'schoolage'.

The closest I think I've gotten is coded below...but I'm still getting error messages. I'm hoping I'm on the right track and it's just a small syntax error:

generate schoolage=. foreach var of varlist hh_* { 2. count if v'=="6 - 10 years of age" |v'=="11 - 14 years of age" 3. }

Aucun commentaire:

Enregistrer un commentaire