06-26-2014 12:57 PM
I have data that takes the following form:
input month y;
And I want to create a column that, each month, calculates the cumulative product of all of the variable Y. So for month 1, it would have a value of 1, then for month 2, it would be 3, then for month 3, it would be 6, and for month 4, it would be 18.
I could do this by transposing the columns, but I have hundreds of observations I need to do this with, so I am trying to find a more elegant way.
Your help is truly appreciated!
06-26-2014 02:26 PM
Yes it does! Thank you very much.
Also, if you don't mind, can you explain what the retain function is doing here so that I can understand how this is working?
Thank you so much!
06-26-2014 03:22 PM
RETAIN tells SAS to keep the value of that variable from data row execution to the next data row. The 1 is to set an initial value, which since you wanted a product 1*value would give the correct first value.
Need further help from the community? Please ask a new question.