%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?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.