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
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.
Ready to level-up your skills? Choose your own adventure.