BookmarkSubscribeRSS Feed
ncsthbell
Quartz | Level 8

I am reading dataset in a sas program (stored process) which was created from another system.  This file has some of the date column formats defined as  'IS8601DN10' and informat as 'DateTime20'.   In viewing the table, the date displays as 'YYYY-MM-DD'.   I am trying to format the date to the format of 'mm/dd/yyyy' and I have not been successful in doing so.     I've spend several hours on this and am quite frustrated.  Any help/suggestions would be greatly appreciated!

 

I have never seen any data come in that used this 'IS860' type format.

 

Thanks for any help that can be offered!!!

3 REPLIES 3
BrunoMueller
SAS Super FREQ

Hi

 

When you are using the IS8601DN10 (documented as E8601DN format), you are actually have a datetime value. So to display it using the MMDDYY. format you need to extract just the date part of the datetime value.

 

The code below illustrates this.

data sample;
  xDate = datetime();
  xDate2 = datepart( xDate );
  format
    xDate IS8601DN10.
    xDate2 mmddyy10.
  ;
run;

proc print data=sample ; 
run;

Bruno

Astounding
PROC Star

I like Bruno's answer better than mine, since it forces you to understand what is in your data.  With that being said, you have enough to work with once you understand that expressing your variable in the IS8601DN10 format gives you YYYY-MM-DD.  Knowing just that much, you could code:

 

newvar = (put(oldvar, IS8601DN10.), yymmdd10.);

 

That gives you NEWVAR as a SAS date, without even knowing what is in OLDVAR.  Just add a format:

 

format newvar mmddyys10.;

Astounding
PROC Star
Meant to add INPUT:

newvar = input(put(oldvar, IS8601DN10.), yymmdd10.);

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1427 views
  • 0 likes
  • 3 in conversation