BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

I'm trying to resolve the error as mentioned below but I'm unable to do it. SCHDLD_OBJ_NM is the variable which I'm creating in the same datastep where I placed the below if condition and I was asked to achieve this one single step.

 

4219       if SCHDLD_OBJ_NM like %"_AP_"% then FNCTL_CMPNT_NM="AP" else "LIS";
                            ____                                     ____
                            388                                      388
                            202                                      202
ERROR 388-185: Expecting an arithmetic operator.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

4220       run;
3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

You use the Like Operator in a Where Statement. If you want to apply the logic in an If Statement, then read 

 

Sample 43303: Using the equivalent of CONTAINS and LIKE in an IF statement

Jagadishkatam
Amethyst | Level 16

You can also try IFC function

 

FNCTL_CMPNT_NM=ifc(indexw(SCHDLD_OBJ_NM,"_AP_"),'AP','LIS');
Thanks,
Jag
hashman
Ammonite | Level 13

@Babloo:

LIKE doesn't like IF, plus your double quotes are extraneous.

Use the FIND function instead. Also, if FNCTL_CMPNT_NM is a new variable not yet seen by the compiler, either declare it in the LENGTH statement as $3 beforehand or reverse the order in which the compiler sees "AP" and "LIS"; otherwise your "LIS" will be truncated to "LI" when "_AP_" is not found in SCHDLD_OBJ_NM:

if find (SCHDLD_OBJ_NM, "_AP_") = 0 then FNCTL_CMPNT_NM = "LIS" ;                                                                                                                                                                                               
else FNCTL_CMPNT_NM = "AP" ;                                         

Kind regards

Paul D.

   

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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