Search code examples
datesassas-macro

Macro variable to SAS date


quick question here.

How could I adapt this code so that it would work with %let DTD=2012-12-31;

%let DTD=31-DEC-2013;

DATA _Null_;
dd="&DTD"d;
put dd;
RUN;

Then dd has a value of 19723. Thanks in advance !


Solution

  • You would have to use INPUT instead of "&var"d;

    dd = input("&DTD",yymmdd10.);
    

    Now, hopefully you wouldn't use 2012-12-32, since that's not a real date. :)