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;
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
You can also try IFC function
FNCTL_CMPNT_NM=ifc(indexw(SCHDLD_OBJ_NM,"_AP_"),'AP','LIS');
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.