08-03-2016 05:54 PM
I have a variable that gets incremented:
and so on. basically I manually increment dependent on adding a shock multiplier to each column. A selection:
state="FL"; shock_no=1; shock_desc="state=FL"; output;
state="CA"; shock_no=2; shock_desc="state=CA"; output;
state="NY"; shock_no=3; shock_desc="state=NY"; output
*as of date;
as_of_date=intnx('month',as_of_date,1); shock_no=4; shock_desc="aod_+1mo"; output;
as_of_date=intnx('month',as_of_date,-2); shock_no=5; shock_desc="aod_-1mo"; output;
And so on. I'm doing this shock entry for a hundren more columns. Instead of having to manually enter the shock_number for each new shock, is there a code snippet that would automatically pick up the last shock_no used and increment by 1?
Thank you very much in advance
08-03-2016 06:20 PM
It is not clear whether you need the value to persist from record to record.
It really helps to have begining input data and what the result should be. Please reduce the data to only what is needed to demonstrate the issue.
This link https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... has instructions on how to create datastep code that we can use to create a working data set to test code.
Need further help from the community? Please ask a new question.