BookmarkSubscribeRSS Feed
cjohnson
Obsidian | Level 7
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.

Thanks,
Chris
Christopher Johnson
www.codeitmagazine.com
1 REPLY 1
data_null__
Jade | Level 19
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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1096 views
  • 0 likes
  • 2 in conversation