BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Rookie_123
Fluorite | Level 6

I have a column/variable named Release_Date with length 8  format 11. and informat 11.

 

The observation in that column are in the form YYYYMMDD. SAS actually reads them as pure number

 

I want to convert those observation in DD/MM/YYYY format with format and informat as DDMMYY10.

 

For example 

 

Release_Date is 20180612 then I want 12/06/2018

 

Any help with this regard will be appreciated

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

One way:

data example;
release_date=20180612; 
release_date = input(put(release_date,8.),yymmdd8.);
format release_date ddmmyy10.;

run;

Another is to go back to when the data were read and use the yymmdd8. informat instead of 11.

 

View solution in original post

4 REPLIES 4
ballardw
Super User

One way:

data example;
release_date=20180612; 
release_date = input(put(release_date,8.),yymmdd8.);
format release_date ddmmyy10.;

run;

Another is to go back to when the data were read and use the yymmdd8. informat instead of 11.

 

Rookie_123
Fluorite | Level 6

I read the date from Access database with PROC IMPORT and the data itself is in the format YYYYMMDD.

So I think while reading itself I will need to reverse the observations to be read as DD/MM/YYYY

 

I dont know if that is possible or not

Rookie_123
Fluorite | Level 6

Thanks the approach mentioned in the answer is perfect for my usecase

ballardw
Super User

SAS a fairly large number of INFORMATS to read dates, times and datetimes in a wide variety of common layouts. It is frequently much easier to find an informat than to write code to parse bits. An important thing to remember is when using the INPUT function that it expects to read a character value and if your variable is actually numeric the default conversion may not work and you may need to use a PUT function call with an appropriate format to match the INFORMAT you want to use in the INPUT call. 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 11342 views
  • 0 likes
  • 2 in conversation