How to replace the asterisk in a date value

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

How to replace the asterisk in a date value

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

 


Accepted Solutions
Solution
‎10-28-2016 11:25 AM
Super User
Posts: 5,513

Re: How to replace the asterisk in a date value

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


All Replies
Solution
‎10-28-2016 11:25 AM
Super User
Posts: 5,513

Re: How to replace the asterisk in a date value

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

 

chardate = compress(chardate, '* ');

numdate = input(chardate, mmddyy10.);

Contributor
Posts: 42

Re: How to replace the asterisk in a date value

Posted in reply to Astounding

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

 

 

 

Super User
Posts: 19,822

Re: How to replace the asterisk in a date value

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

Super User
Posts: 19,822

Re: How to replace the asterisk in a date value

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
Contributor
Posts: 42

Re: How to replace the asterisk in a date value

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

 

I appreciate all your help.

 

 

Respected Advisor
Posts: 4,926

Re: How to replace the asterisk in a date value

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

PG
Contributor
Posts: 42

Re: How to replace the asterisk in a date value

Posted in reply to Astounding

Thank you. I appreciate all the help for everyone.

 

Happy Friday.

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 559 views
  • 0 likes
  • 4 in conversation