BookmarkSubscribeRSS Feed
Srigyan
Quartz | Level 8

I am trying to find following value in 

('BLACK','BF','CYBER','PRE WEEK')

in event_name and wrote the code

if find(upcase(event_name),('BLACK','BF','CYBER','PRE WEEK')) AND find(upcase(season ),'AW') then EVENT_FLAG='CLEARANCE';

its showing following error

 

32         if find(upcase(event_name),('BLACK','BF','CYBER','PRE WEEK')) AND find(upcase(season ),'AW') then EVENT_FLAG='CLEARANCE';
                                              _                        _
                                              79                       22
                                                                       200
              ____
              72
ERROR 79-322: Expecting a ).

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, 
              IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, THEN, ^, ^=, |, ||, ~, ~=.  

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

ERROR 72-185: The FIND function call has too many arguments.

Can some one help so I can search all these string.

3 REPLIES 3
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

if upcase(event_name) in ('BLACK','BF','CYBER','PRE WEEK') AND upcase(season) in ('AW') then EVENT_FLAG='CLEARANCE';

hashman
Ammonite | Level 13

@Srigyan:

You aren't telling us clearly what kind of logic you're trying to implement, nor this is apparent from your code. Let's see:

 

1. If, as you say, you want to find whether the entire string value 'BLACK','BF','CYBER','PRE WEEK' (replete with the single quotes) is contained in upcase(event_name), then:

if find (upcase (event_name), "'BLACK','BF','CYBER','PRE WEEK'") and ...

  

2. On the other hand, if (as I strongly suspect), you want to find If EVENT_NAME contains any of the strings 'BLACK','BF','CYBER','PRE WEEK', then:

if (find (upcase (event_name), 'BLACK') 
  or find (upcase (event_name), 'BF')
  or find (upcase (event_name), 'CYBER')
  or find (upcase (event_name), 'PRE WEEK')  
) and ...

3. If you want to find If EVENT_NAME contains any of the words 'BLACK','BF','CYBER','PRE WEEK', then use the FINDW function instead of FIND.

 

Kind regards

Paul D.
   

Ksharp
Super User
if prxmatch('/BLACK|BF|CYBER|PRE WEEK/i',even_name) then .....
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1186 views
  • 4 likes
  • 4 in conversation