Saturday, April 2, 2016

SAS: Select datetime field into a macro variable

How to select a datetime field into a macro variable, and use it later...
  1. use format=date16.
  2. enclose macro variable in quotes, followed by dt


proc sql noprint;
select max(dttm) format=date16. into :max_dttm from some_table;
quit;run;

data work.subset;set work.my_input (where=(dttm = "&max_dttm"dt));
* etc. ;
run;