In the below code, I want the macro variable REPORTINGDATE to resolve as 31MAR2007. So I would like to know what value to be passed as Input for the variable x.
data _null_;
x=input(put(&reportingdate,$8.),yymmdd8.);
format x date9.;
call symput('REPORTINGDATE',x);
run;
%let reportingdate=20070331;
data _null_;
x = input("&reportingdate",yymmdd8.);
call symput('reportingdate',put(x,date9.));
run;
Note that in most cases, you won't need a formatted date in the macro variable. For calculations and comparisons, the raw value is easier to handle.
And if you want the date displayed, use a better format like e8601da10. (equal to yymmddd10.).
What is the initial value of &Reportingdate?
%let reportingdate=20070331;
data _null_;
x = input("&reportingdate",yymmdd8.);
call symput('reportingdate',put(x,date9.));
run;
Note that in most cases, you won't need a formatted date in the macro variable. For calculations and comparisons, the raw value is easier to handle.
And if you want the date displayed, use a better format like e8601da10. (equal to yymmddd10.).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.