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

Hi...I am trying to convert a character date to numeric date. The character date is in the formate of weekdate17. I can't seem to get it converted.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Then go for:

 

SASdate = input(cats(scan(myDate,3), scan(myDate, 2), scan(myDate, 4)), date9.);

PG

View solution in original post

5 REPLIES 5
PGStats
Opal | Level 21

Try

 

SASdate = input(cats(substr(myDate,10, 2), substr(myDate, 6, 3), substr(myDate,14, 4)), date9.);

PG
ballardw
Super User

You may need to provide some actual examples. This example may give you a starting point.

data junk;
   x= 'Tuesday, June 1, 2016';
   y=input(substr(x,index(x,' ')),anydtdte15.);
   format y mmddyy10.;
run;


twildone
Pyrite | Level 9

HI PGStats/Ballardw......Thanks for both your suggestions. I tried both of them and they gave me the exact same results with one problem. When the date had a single interger for the day number in the date ( Thu. May 7, 2015) , it produced a blank space otherwise worked perfect. Thanks

 

ballardw
Super User

We would have to see your data and the actual code you ran to see what was generating the space.

I can't duplicate the issue with your Thu. May 7, 2015 example even inserting an additional space into the input between the month and the day of the month. It may be you have some sort of non-printable character or a double-byte conversion issue.

PGStats
Opal | Level 21

Then go for:

 

SASdate = input(cats(scan(myDate,3), scan(myDate, 2), scan(myDate, 4)), date9.);

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 5 replies
  • 891 views
  • 0 likes
  • 3 in conversation