BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

In my data vdate variable contains the following values.  I used the following code to convert to isodate. But it gives me " Invalid argument to function INPUT function".

Pleas help why.]

I think my code looks ok.

 

 

id              vdate(character)

1               17/Jul/2015                

2

3                UN/Jan/2016

 

 

code; 

 

if vdate  ^= ''  or compress(vdate,'/') ^= : 'UN' then date1=put(input(vdate,date11.),is8601da.);

 

;

           

 

3 REPLIES 3
Reeza
Super User

The log should tell you the offending record which should help you narrow down the issue in your logic. 

 

Also, verify if you want OR or AND

Shmuel
Garnet | Level 18

What you realy meant by: 

        if vdate  ^= ''  or compress(vdate,'/') ^= : 'UN' then date1=put(input(vdate,date11.),is8601da.);

 

is   if   NOT (vdate = ' '  or compress(vdate,'/') = : 'UN' )  then date1=put(input(vdate,date11.),is8601da.);

 

which, after opening the brackets convert into:

     if vdate  ^= ' '  AND  compress(vdate,'/') ^= : 'UN' then date1=put(input(vdate,date11.),is8601da.);

 

Other solution is:    date1=put(input(vdate,?? date11.),is8601da.);

which in case of vdate is not valid then date1 is missing value.

 

 

 

 

Astounding
PROC Star

While I agree with the earlier comments, it might be easiest to understand the observations you are processing if you switched to:

 

if not (vdate in : (' ', 'UN')) then .....;

 

The way you have written the logic, every single observation meets the IF conditions.

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
  • 3 replies
  • 1075 views
  • 3 likes
  • 4 in conversation