Hi,
I know this is a subject on wich there is alot of forum posts already but I was not able to find a solution for my problem.
I have a dataset with dates in the characther (L:10 Format:$10 Informat:$10) format "yyyy-mm-dd" and I want to transform them to a SAS numeric date, or add a new variable with the SAS numeric date. I have been trying to use the informat E8601DAw. in different ways but I may be using it wrong.
date=input(olddate, E8601DAw.);
run;
This gives me an error on the informat E8601DAw and 0 observations.
Is there another informat I should use to transform the dates from characther to sas date? Should I be using a different code?
I would be highly gratefull for any response,
thank you in advance.
lower case w in is the width specification should be number or use default.
15 data _null_;
16 olddate = '2019-09-25';
17 date=input(olddate, E8601DA.);
18 put date= date=date11.;
19 run;
date=21817 date=25-SEP-2019
cdate = '2019-02-17';
date = input(cdate,yymmdd10.);
data test;
olddate='2019-09-25';
date=input(olddate, yymmdd10.);
format date yymmdd10.;
run;
The lowercase "w" stands for width and needs to be replaced by a suitable number, in your case 10.
lower case w in is the width specification should be number or use default.
15 data _null_;
16 olddate = '2019-09-25';
17 date=input(olddate, E8601DA.);
18 put date= date=date11.;
19 run;
date=21817 date=25-SEP-2019
Thank you very much for your response. Thanks for the info! It finally worked but had to remove
olddate = '2019-09-25'
I really apreciate your help!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.