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

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.

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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

 

 

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26
cdate = '2019-02-17';
date = input(cdate,yymmdd10.);
--
Paige Miller
PeterClemmensen
Tourmaline | Level 20
data test;
    olddate='2019-09-25';
    date=input(olddate, yymmdd10.);
    format date yymmdd10.;
run;
data_null__
Jade | Level 19

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

 

 

Viktoreli
Obsidian | Level 7

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!

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1467 views
  • 5 likes
  • 5 in conversation