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

I would be most appreciative for any help someone could give me.

 

I have date values in records where the data scanning process (for some reason) includes an asterisk within the date value. The date is converted to a string when it's scanned so the asterisk is allowed. I can convert the string date to a true date but I am faced with multiple errors because of the asterisks. I've tried various iterations of tranwrd and compress but I can't seem to get it right. I think, (perhaps mistakenly), that the asterisk is being treated as a wildcard in those functions?

 

Alternatively I could simple exclude anything that is not a valid date since the imperfect scanning process gives me results such as:

00/23/2009

04/2 /90 9

 

Thanks for any help you might be able to provide.

 

Sample data:

*6/08/2009

5/*1/2009

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

You're using the right tools ... maybe just not quite in the right way.  Try:

 

chardate = compress(chardate, '* ');

numdate = input(chardate, mmddyy10.);

View solution in original post

7 REPLIES 7
Astounding
PROC Star

You're using the right tools ... maybe just not quite in the right way.  Try:

 

chardate = compress(chardate, '* ');

numdate = input(chardate, mmddyy10.);

Jeff_DOC
Pyrite | Level 9

Thank you for the response but it doesn't work. It could be I have something else going on here. Here is what I used:

 

temp_date = compress(date,'*');

surveydate = input(temp_date,mmddyy10.);

 

And here is what I got back:

 

NOTE: Invalid argument to function INPUT at line 24 column 15.

 

month=June2009 idnumber=111111111 date=06/04/* 77

 

 

 

Reeza
Super User

Post the actual log. For example, what's the value of temp_date.  

Reeza
Super User

Look very closely at @Astounding code sample. It includes both an asterisk AND a space in the arguments to the compress function. 

If you modify your compress function it will work.

 

If you look at the error in your log closely you'll see the extra space (red underscore here).

NOTE: Invalid argument to function INPUT at line 58 column 14.
surveydate=. date=06/04/* 77 temp_date=06/04/_77 _ERROR_=1 _N_=1
Jeff_DOC
Pyrite | Level 9

Thanks for calling my attention to that. I didn't see it.

 

I appreciate all your help.

 

 

PGStats
Opal | Level 21

You got month=June2009 and  date=06/04/* 77, are those two fields supposed to be related?

PG
Jeff_DOC
Pyrite | Level 9

Thank you. I appreciate all the help for everyone.

 

Happy Friday.

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 3300 views
  • 0 likes
  • 4 in conversation