Hi there,
I'm trying to generate prevalence variable based on the calculation of two variables in the dataset.
How would I condense the following into a loop (I want to create separate variables for the years 2007 to 2018):
gen lsoapsyprev_2007 = (lsoapsych_2007/ LSOAmye_pop2007)*100
gen lsoapsyprev_2008 = (lsoapsych_2008/ LSOAmye_pop2008)*100
gen lsoapsyprev_2009 = (lsoapsych_2009/ LSOAmye_pop2009)*100
Many thanks
I'm trying to generate prevalence variable based on the calculation of two variables in the dataset.
How would I condense the following into a loop (I want to create separate variables for the years 2007 to 2018):
gen lsoapsyprev_2007 = (lsoapsych_2007/ LSOAmye_pop2007)*100
gen lsoapsyprev_2008 = (lsoapsych_2008/ LSOAmye_pop2008)*100
gen lsoapsyprev_2009 = (lsoapsych_2009/ LSOAmye_pop2009)*100
Many thanks
Comment