data test;
informat dt datetime16.;
format dt datetime16.;
dt="23Sep18:11:32:00"dt;
dtChar=put(dt, datetime16.);
run;
data test;
informat dt datetime16.;
format dt datetime16.;
dt="23Sep18:11:32:00"dt;
dtChar=put(dt, datetime16.);
run;
Note that formats are instructions for how to convert values into character strings for display purposes.
Sounds like you want to create a new VARIABLE that is character instead of numeric.
data want ;
set have ;
length char_date $16 ;
char_date = put(real_date,datetime16.);
run;
I would highly recommend not using a format that does not display the century for dates.
Note that there is bug (feature?) of the DATETIME format that makes it not use 4 digit years when use a width of 18. So use a width of 19 instead and add the -L format option or LEFT() function call to remove the leading space.
data want ;
set have ;
length char_date $18;
char_date = put(real_date,datetime19.-L);
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.