Hi I am trying to create variables that are the sum of weighted observations from variables one, two, three, four, and five over a flexible rolling time frame. Here is an example of what I am trying to do: create variable named 2004 = ([(.1)*(one + two + three + four + five)]where year=2005) + ([(.1)*(one + two + three + four + five)]where year=2006) + .. + ([(.1)*(one + two + three + four + five)]where year=2010) create variable named 2005 = ([(.1)*(one + two + three + four + five)]where year=2006) + ([(.1)*(one + two + three + four + five)]where year=2007) + .. + ([(.1)*(one + two + three + four + five)]where year=2011) The idea is to create a variable that is the sum of weighted observations from the ten subsequent years. I understand how to explicitly write this out in the data step per variable created. I would like to understand how to more efficiently code the flexible year specification part. Below is a simple example of what the data looks like. year one two three four five 2005 36,565,000 38,964,000 43,091,000 41,709,000 64,508,000 2006 36,761,000 39,090,000 42,869,000 42,619,000 66,213,000 2007 37,282,000 39,514,000 42,582,000 43,291,000 67,981,000 2008 37,342,000 39,707,000 41,966,000 43,723,000 69,878,000
... View more