I have a range of variables for counts of diagnoses each beginning "cat_" and another variable "population"
I would like to create a new variable of the incidence e.g. "inc_cat_cardio"
I can do this using:
However if I do:
I get the following error: "/population invalid name"
Help suggests that this is a typo but I have checked this and am using exactly the same spelling with and without foreach
Can anybody advise on what I am doing wrong?
Thanks
I would like to create a new variable of the incidence e.g. "inc_cat_cardio"
I can do this using:
Code:
gen inc_cat_cardio = cat_cardio / population
Code:
foreach cat of var cat* { gen inc_`var' = `var' / population }
Help suggests that this is a typo but I have checked this and am using exactly the same spelling with and without foreach
Can anybody advise on what I am doing wrong?
Thanks
Comment