BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Bal23
Lapis Lazuli | Level 10

 

My code is below:

if upcase(substr (variablea,1,1)) in ('O''P') then delete;
 variableb = input(substr(variable,1,3), 8.);

 

Check the data it generates, i still see "O" exist and that is why for the second statement, it generates missing data.

"NOTE: Invalid argument to function INPUT at line 581 column 17"

 

would anybody give advice how to fix the problem? what is wrong with my code?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Please mark the solution as correct on the forum.

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You have a typo in your code:

if upcase(substr(variablea,1,1)) in ('O','P') then delete;
variableb=input(substr(variable,1,3), 8.);

Note the comma separating the elements in the in() list.

PGStats
Opal | Level 21

You need a comma between the apostrophes 'O''P' -> 'O','P' . The way it reads now is upcase(substr (variablea,1,1)) should be equal to O'P

PG
ballardw
Super User

IN operator requires either a comma or a blank space between elements to compare. With neither the two quotes in the middle are treated as a single quote.

 

Since the records with O or P values in the first column were not deleted then you have the input function trying to read something like P12 as numeric and failing.

Bal23
Lapis Lazuli | Level 10

Thank you, everyone. It is solved!

Reeza
Super User

Please mark the solution as correct on the forum.

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