DATA Step, Macro, Functions and more

finding values that begin with specific letter---getting error

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 121
Accepted Solution

finding values that begin with specific letter---getting error

Hi!

 

I am trying to identify all values that do not begin with certain letters...and set them to missing.

 

    if patrank ne: ('E','W','O','C','U') then do;
            patrank='';
        end;

 

THis gave me an error...

3616              if patrank ne: ('E','W','O','C','U') then do;
                                     -                      --
                                     388                    180
                                     200
ERROR 388-185: Expecting an arithmetic operator.

ERROR 180-322: Statement is not valid or it is used out of proper order.

ERROR 200-322: The symbol is not recognized and will be ignored.

3617              patrank='';
3618          end;
              ---
              161
ERROR 161-185: No matching DO/SELECT statement.

Accepted Solutions
Solution
a week ago
PROC Star
Posts: 162

Re: finding values that begin with specific letter---getting error

Try in

 

  if patrank in : ('E','W','O','C','U') then do;

View solution in original post


All Replies
Solution
a week ago
PROC Star
Posts: 162

Re: finding values that begin with specific letter---getting error

Try in

 

  if patrank in : ('E','W','O','C','U') then do;
Super User
Posts: 10,466

Re: finding values that begin with specific letter---getting error

Or:

data example;
   input patrank $;
   if not ( patrank in : ('E','W','O','C','U') ) then call missing(patrank);
datalines;
This
Other
words
Can
use
Word 
case
;
run;

is the comparison supposed to be case sensitive? If you want to match "case" as well as "Can" then use upcase(patrank) in the comparison.

 

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 80 views
  • 1 like
  • 3 in conversation