Here is a macro that uses the %ut_varlist macro documented in https://communities.sas.com/t5/SAS-Programming/Macro-function-to-return-a-list-of-variables-in-a-table-in-a/m-p/633536
(Download the attachment, add them to your sasautos macro library (or %include).
See example 10 in the above posting....
%macro set_data_fmts(table=);
%local datecols datetimecols lib memname;
%let datecols=%ut_varlist(table=&table., type=DATE);
%let datetimecols=%ut_varlist(table=&table., type=DATETIME);
%let lib=%scan(&table.,-2);
%if &lib.=%str() %then %let lib=work;
%let memname=%scan(&table.,-1);
proc datasets library=&lib. nolist;
modify &memname.;
format &datecols. yymmdd10.;
format &datetimecols. E8601DN10.;
quit;
%mend set_data_fmts;
The above macro just changes formats in the column metadata. However, since DB2 stores all dates as datetimes, you may need to convert
dates into datetimes using something like:
/* convert all dates into timestamps */
data &table.;
set &table.;
array datecols &datecols;
do _i_=1 to dim(datecols);
datecols(_i_) =dhms(datecols (_i_),0,0,0);
end;
run;
... View more