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

Hi everyone,

How can I read this type of dates in eGuide?

Tuesday, 11th June 1985

Monday, 4th June 1990


Thx!

David

1 ACCEPTED SOLUTION

Accepted Solutions
DavidDemeyer
Calcite | Level 5

Tis fixed the problem:

data test;

F5='Friday, 10th January 1986';

worddate=left(scan(F5,2,','));

day=substr(worddate,1,2);

monthname=scan(worddate,2, ' ');

month=substr(monthname,1,3);

year=scan(worddate,3,' ');

date9=input(catt(day,month,year),date9.);

run;

proc print ; run;

View solution in original post

3 REPLIES 3
TomKari
Onyx | Level 15

I don't think you'll be able to read these without doing some further processing. Are they always in the form

<weekday>, <date>th <month> <year>

If they are, it is very easy to reformat them to be converted.

Tom

DavidDemeyer
Calcite | Level 5

Tis fixed the problem:

data test;

F5='Friday, 10th January 1986';

worddate=left(scan(F5,2,','));

day=substr(worddate,1,2);

monthname=scan(worddate,2, ' ');

month=substr(monthname,1,3);

year=scan(worddate,3,' ');

date9=input(catt(day,month,year),date9.);

run;

proc print ; run;

TomKari
Onyx | Level 15

Perfect. That's exactly the way to do things like this in SAS.

Your day assignment may not work with single digit dates.

day=substr(worddate,1,(notdigit(worddate)-1));

should fix it.

Tom

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 875 views
  • 0 likes
  • 2 in conversation