BookmarkSubscribeRSS Feed
NewUsrStat
Lapis Lazuli | Level 10

Hi guys, 

 

I have a dataset DB with two variables: patient ID and date: 

 

data DB;
  ID date;
cards;
1 2013-11-13
2 2024-01-12
3 2025-01-10
4 2025-10-17
5 2024-11-15
6 2025-11-12
7 2025-10-08
;run;

I would like to format the date according to ISO 8601 standard for SDTM formatting. I'm new in the field. 

I need a char variable at the end.

 

Can anyone help me please? 

 

Thank you in advance

2 REPLIES 2
Tom
Super User Tom
Super User

It is not clear what you are starting with since the code you shared cannot run.

 

If the variable you named DATE is an actual SAS date variable then it is NUMERIC.  In order to create a CHARACTER variable you will need to use a different variable name.  And if it is an actualy date variable it cannot contain any partial date values, so you can ignore the SDTM specifications for how to represent partial date values.

 

To convert a date value into a character value in the style YYYY-MM-DD you can either the YYMMDD10. format,  Or the YYMMDDD10. format, the extra D stands for DASH.  Or use the E8601DA10. format.

data want;
  set db;
  charvar=put(date,yymmdd10.);
run;

If your variable is character and looks like the text in your example then you don't need to do anything since it is already in that style.

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 save with the early bird rate—just $795!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 355 views
  • 2 likes
  • 3 in conversation