BookmarkSubscribeRSS Feed
avatar
Fluorite | Level 6


Hello,

I would like to bring data 10 days older from the start date.

I have created a macro for start date shown below.

%let start_dt = '01APR2014'd ;

% let old_dt = %eval(%input(&start_dt ,8.)  -  10);

this gives erro

4 REPLIES 4
ChrisHemedinger
Community Manager

Dates are just numbers, so the easy thing to do is to ensure you seed your %EVAL expression with them as numbers using SAS functions.

Examples:

/* 10 days before today */
%let cutoff = %eval(%sysfunc(today()) - 10);

/* 10 days before April 1, 2014 */
%let cutoff = %eval(%sysfunc(mdy(4,1,2014)) - 10);

Chris
SAS Innovate 2025: Call for Content! Submit your proposals before Sept 25. Accepted presenters get amazing perks to attend the conference!
user24feb
Barite | Level 11

%LET old_dt=%Sysfunc(PutN(%Sysfunc(IntNX(day,&start_dt.,-10)),Date9.));

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, few things there.  The start_dt macro variable will contain the text '01APR2014'd

when this resovles on the eval you will get: %let old_dt = %eval(%input('01APR2014'd ,8.)  -  10);

This will fail as there is a d after the quote.  Also, you have a space between the % and let.  

I would question why you need to do this as:

data _null_;

     call symput('OLD_DT','01APR2014'd - 10);

run;

would give the result, plus several other methods of getting there.

avatar
Fluorite | Level 6

Chris example seems simple to use. I will try that.

thanks all

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 1308 views
  • 3 likes
  • 4 in conversation