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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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