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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.