Hi SAS friends, Am trying to use the index function to locate a string variable " MrgMT" in a longer string variable " Merge_term " , but it is not working as expected. Have checked the source datasets for hidden characters and "purged" them with a compress function (used the "KAS" option to keep only alphanumeric characters and some symbols), and viewed them in note pad looking for bad characters, but still no luck. I've uploaded a sample SAS file with these thee variables. Here is the code data lcl.Index_Prob ; set lcl.&FFN._TMP ;
Where MrgMT in ("ALBUTEROL", "ACAMPROSATE")
and
Merge_term in ("4MG OF ALBUTEROL", "ALBUTEROL", "ACAMPROSATE", "ACAMPROSATE (CAMPRAL)");
Merge_No = index(Merge_term, MrgMT) ;
keep MrgMT Merge_term Merge_No ;
run ; Here is an example of the output, with comments: Merge_term MrgMT Merge_No Should be 4MG OF ALBUTEROL ALBUTEROL 0 8 ACAMPROSATE ACAMPROSATE 1 OK ! ACAMPROSATE ALBUTEROL 0 OK ! ACAMPROSATE (CAMPRAL) ACAMPROSATE 0 1 ALBUTEROL ALBUTEROL 1 OK! Any suggestions on why INDEX function is not working? Thank you !
... View more