BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JohnWiz
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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.

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

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.

JohnWiz
Calcite | Level 5

awesome.  hadn't even bother trying a proc yet.  Thanks a bunch.

Doc_Duke
Rhodochrosite | Level 12

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1112 views
  • 2 likes
  • 3 in conversation