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
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:
%LET old_dt=%Sysfunc(PutN(%Sysfunc(IntNX(day,&start_dt.,-10)),Date9.));
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.
Chris example seems simple to use. I will try that.
thanks all
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.
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.