I have a simple data step to export a data set to a text file.
DATA _NULL_ ;
FILE "filename" DSD DLM='~' ;
SET table;
PUT (_ALL_)(:) ;
RUN;
However, I need to change the format of all date variables. Is there any way to do this other than formatting each variable? I have a hundred or so tables, each with many date variables.
It depends on how you can identify the variables that need to be "reformatted".
If they have names that begin with DT then you can write
[pre]format DT: mmddyy10.;[/pre]
or you might use SQL and create a list of names base on current format and change the format that way.
[pre]
proc sql;
select name into :datevars separated by ' '
from dictionary.columns
where libname et '....' and memname eq '....' and format eqt 'date';
quit;
....
format &datevar mmddyy10.;
....
[/pre]
You will need to lookup the details with regards to dictionary.columns
The 2025 SAS Hackathon Kicks Off on June 11!
Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.