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

I'm looking for an efficient way to convert a column that has mixed dates to YYYY-MM-DD.

Your help is aprreciated

 

Raw_Date

01 NOV 2019

01-NOV-19

 

Corrected_Date

2019-11-01

2019-11-01

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Hi, For your sample Raw data , date11 is a natural informat.

 

/*reading as raw data*/
data have;
input date date11.;
format date yymmdd10.;
cards;
01 NOV 2019
01-NOV-19
;
/*If it's a sas dataset*/
data have;
input date $11.;
cards;
01 NOV 2019
01-NOV-19
;

data want;
set have;
new_date=input(date,date11.);
format new_date yymmdd10.;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Hi, For your sample Raw data , date11 is a natural informat.

 

/*reading as raw data*/
data have;
input date date11.;
format date yymmdd10.;
cards;
01 NOV 2019
01-NOV-19
;
/*If it's a sas dataset*/
data have;
input date $11.;
cards;
01 NOV 2019
01-NOV-19
;

data want;
set have;
new_date=input(date,date11.);
format new_date yymmdd10.;
run;
r_behata
Barite | Level 11
data have;
input Raw_Date ANYDTDTE.;
Raw_Date_New=put(Raw_Date,yymmddd10.);

put Raw_Date_New =;
cards;
01 NOV 2019
01-NOV-19
;
run;

Log :

 

 Raw_Date_New=2020-11-01
 Raw_Date_New=2019-11-01

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