Hi all,
I have a variable that gets incremented:
shock_number =1
shock_number=2
and so on. basically I manually increment dependent on adding a shock multiplier to each column. A selection:
_base_state=state;
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
state=_base_state;
*as of date;
_base_aod=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;
as_of_date=_base_aod;
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
If you want to increase the value of a variable by 1 then just add 1 to it.
shock_no=shock_no+1;
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.
If you want to increase the value of a variable by 1 then just add 1 to it.
shock_no=shock_no+1;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.