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
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;
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;
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
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: