BookmarkSubscribeRSS Feed
JillChen0131
Fluorite | Level 6

I have a numeric version of datetime, like13DEC2021:10:28:00. I would like to convert it to character format like yyyy-mm-dd:hh:mm. Thanks for your help

 

1 REPLY 1
Reeza
Super User

Why character? Teradata load?

 

https://communities.sas.com/t5/SAS-Data-Management/Timestamp-format-of-YYYY-MM-DD-HH-MM-SS/td-p/3146...

 

Otherwise I typically recommend the ISO format. 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/leforinforref/n03vr57gdozvean1klfaaa14c9c0.ht...

 

proc format;
picture dtpic
other='%Y-%0m-%0d %0H:%0M:%0S' (datatype=datetime)
;
run;

data a;
 a = datetime();
length b $30.;
 b = put(a, dtpic.);
 format a dtpic.;
run;

 

 

 

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
  • 900 views
  • 2 likes
  • 2 in conversation