DATA Step, Macro, Functions and more

substract, input, etc

Accepted Solution Solved
Reply
Super Contributor
Posts: 336
Accepted Solution

substract, input, etc

 

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


Accepted Solutions
Solution
‎01-13-2016 01:52 PM
Super User
Posts: 17,829

Re: substract, input, etc

Please mark the solution as correct on the forum.

View solution in original post


All Replies
Super User
Super User
Posts: 7,401

Re: substract, input, etc

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.

Respected Advisor
Posts: 4,649

Re: substract, input, etc

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
Super User
Posts: 10,500

Re: substract, input, etc

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.

Super Contributor
Posts: 336

Re: substract, input, etc

Thank you, everyone. It is solved!

Solution
‎01-13-2016 01:52 PM
Super User
Posts: 17,829

Re: substract, input, etc

Please mark the solution as correct on the forum.

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 400 views
  • 0 likes
  • 5 in conversation