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.);

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 958 views
  • 0 likes
  • 3 in conversation