Multiplying a scalar by a bunch of years
Posted: Fri Dec 13, 2013 8:31 am
Hello,
I have a rate calculated for the year 2012, and population projections for the years 2012-2036.
I want to multiply the rate for 2012 by the population each year from 2012-2036. Currently my code is only multiplying the rate from 2012 by the population from 2012 and giving me NA for the rest of the years.
Ideally I would like to create a for loop that does this for me (i.e., for 2012 to 2036... multiply the 2012 rate by the population each year) however I do not know how to do this.
This is my code:
Is there a simply way to do this?
Alternatively I could copy the rate from 2012 and apply it to every year 2012-2036, but I don't know how to do this either.
Hope you can help.
Thanks
I have a rate calculated for the year 2012, and population projections for the years 2012-2036.
I want to multiply the rate for 2012 by the population each year from 2012-2036. Currently my code is only multiplying the rate from 2012 by the population from 2012 and giving me NA for the rest of the years.
Ideally I would like to create a for loop that does this for me (i.e., for 2012 to 2036... multiply the 2012 rate by the population each year) however I do not know how to do this.
This is my code:
Code: Select all
'Calculate 2012 Use Rates and create a new page for it
pagecreate(page=RATE) a 2012 2012
copy LTC\b* RATE\b*
copy(smpl="2012 2012") POP\* RATE\*
for %g f m
for %c 6569 7074 7579 8084 85plus
smpl 2012 2012
series r{%g}{%c}=b{%g}{%c}/p{%g}{%c}
next
next
'Projections
pagecreate(page=PROJ) a 2012 2036
copy POP\* PROJ\*
copy RATE\r* PROJ\r*
for %g f m
for %c 6569 7074 7579 8084 85plus
series ltc{%g}{%c}
ltc{%g}{%c}=r{%g}{%c}*p{%g}{%c}
next
next
Alternatively I could copy the rate from 2012 and apply it to every year 2012-2036, but I don't know how to do this either.
Hope you can help.
Thanks