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. 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 4 replies
  • 12301 views
  • 0 likes
  • 2 in conversation