SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Date format

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Date format

Hi all, 

 

 I want to change the date format of my data to YYMMDD8. . The data has two different date formats. They are:

1. DD/MM/YY (DDMMYYw.)

2. DD/MM/YYYY (DDMMYY10.)

Usually, I use the code below to change the date to the needed format.

Dateform = INPUT(PUT(date,8.),YYMMDD8.);
FORMAT Dateform YYMMDD8.;
RUN;

 

However, when I run the code now, it reads the 'day' as 'year' for both date formats. Please how can I solve this problem? Thank you .

 


Accepted Solutions
Solution
‎08-04-2016 04:34 AM
Super User
Super User
Posts: 6,500

Re: Date format

It is reading the DD as the YY because that is what you told it do by using the YYMMDD informat instead of the DDMMYY informat.

 

Is your data in a numeric variable? If so then why did you show the values as having slashes in them?

Is your data in a character variable?  If so then just use the INPUT() function on it.  You should use a width of 10 to handle both the records with and without the century part of the year.

Dateform = INPUT(date,DDMMYY10.);

 

View solution in original post


All Replies
Super User
Super User
Posts: 7,401

Re: Date format

Can you clarify, you have data which is in SAS numeric date format?  If so then you just need to apply the format statement, you wouldn't input(put) it again.

Solution
‎08-04-2016 04:34 AM
Super User
Super User
Posts: 6,500

Re: Date format

It is reading the DD as the YY because that is what you told it do by using the YYMMDD informat instead of the DDMMYY informat.

 

Is your data in a numeric variable? If so then why did you show the values as having slashes in them?

Is your data in a character variable?  If so then just use the INPUT() function on it.  You should use a width of 10 to handle both the records with and without the century part of the year.

Dateform = INPUT(date,DDMMYY10.);

 

Contributor
Posts: 25

Re: Date format

Thank you. Dateform=INPUT(date,MMDDYY10.); works.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 397 views
  • 1 like
  • 3 in conversation