I have a table with a column containing Effective Dates in DDMMMYYYY format. Expiration Date values don't exist on the table so I need to create my own values for 'Expiration Date'. I need to Select (EFFECTIVE_DATE - 1 as EXPR_DATE) essentially so that if the Effective Date reads 02APR2011 the new field EXPR_DT will show 01APR2011.
Can anyone help me please?
If you are doing it in proc sql you already have the correct syntax if you leave off the parentheses.
A SAS date - 1 is equal to the SAS date of the prior day. Thus, in a datastep, EXPR_DATE=EFFECTIVE_DATE - 1; would work.
If you are doing it in proc sql you already have the correct syntax if you leave off the parentheses.
A SAS date - 1 is equal to the SAS date of the prior day. Thus, in a datastep, EXPR_DATE=EFFECTIVE_DATE - 1; would work.
awesome. hadn't even bother trying a proc yet. Thanks a bunch.
SAS stores dates internally as the number of days from 1/1/1960, so date arithmetic is simple. If effective_date is a SAS date, then
expr_dt = effective_date-1;
FORMAT expr_dt date9.;
should do it. If effective_date is a character string, then you need to first convert it to a SAS date using the INPUT function, like
effective_date_new= INPUT(effective_date, anydate9.);
Doc Muhlbaier
Duke
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: