%let sales_date = "01JAN2018"d;
proc ds2;
data sales_data/overwrite = 'YES';
retain count;
method run();
set {select * from sales.sales_data where sales_date >=&sales_date. };
end;
enddata;
run;
quit;
Hi , I want to understand how to use macro date variable in PROC DS2. sales_date is macro variable and want to use fetch data from sas dataset sales.sales_data after this date. There has been lot of other codes also so jsut added only relevant code to show what is needed. Overall, how to use macro variable in proc ds2 which is sas date.
Like this?
%let sales_date = '01jan2018'd;
data TEST;
D='01jan2018'd;
run;
proc ds2;
data T/overwrite = 'YES';
method run();
set { select * from TEST where D = date%nrbquote('%sysfunc(putn(&sales_date.,yymmddd10.))') };
end;
enddata;
run;
quit;
NOTE: Execution succeeded. One row affected.
Macro variables work fine.
Your syntax is incorrect.
This works:
%let sales_date = date'2018-01-01';
data TEST;
D='01jan2018'd;
run;
proc ds2;
data T/overwrite = 'YES';
method run();
set { select * from TEST where D = &sales_date. };
end;
enddata;
run;
quit;
NOTE: Execution succeeded. One row affected.
Like this?
%let sales_date = '01jan2018'd;
data TEST;
D='01jan2018'd;
run;
proc ds2;
data T/overwrite = 'YES';
method run();
set { select * from TEST where D = date%nrbquote('%sysfunc(putn(&sales_date.,yymmddd10.))') };
end;
enddata;
run;
quit;
NOTE: Execution succeeded. One row affected.
PROC DS2 does not understand SAS date literals?
Who made that design decision?
What other types of SAS literals does PROC DS2 not understand?
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.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.