I have a column calls as_of_date which is a character filed and the format is yyyy-mm-dd like 2020-05-01. How do I convert it to numeric?
I tried input(as_of_date, DDMMYY10.) and several of other formats but they did not work.
Thanks.
data test;
dt1 = '2020-05-01';
dt2 = input(dt1, yymmdd10.);
format dt2 yymmdd10.;
run;
When you have a YMD order in the data, you need a YMD informat, so try
input(as_of_date,yymmdd10.)
data test;
dt1 = '2020-05-01';
dt2 = input(dt1, yymmdd10.);
format dt2 yymmdd10.;
run;
Hint in reading informat and format descriptions:
YY = year (2 or 4 digits)
MM = month number
DD = day of month number
So when your data is in year month day order it becomes a bit more obvious that you want some form of YYMMDD informat/format.
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.