Hi everyone, If I have a dataset that looks like the following (with ~5,000 rows). The VariableList contains strings with certain prefix ("string*") as well as other numbers and characters, always separated by space. ID VariableList A1 stringA stringB 123 A2 stringA + stringB > stringC A3 stringA A4 stringB stringC 456 A5 stringC stringD abc And I want to search for units where in the VariableList, the words with prefix include words from a list ("stringA" or "stringB"), but no other prefixed words ("StringC", "StringD", etc). I don't care about the extra strings. So in this example, I want the new dataset to only contain ID VariableList A1 stringA stringB 123 A3 stringA I found a similar question (https://communities.sas.com/t5/SAS-Procedures/searching-words-in-a-variable/td-p/85846) and tried the PRX function as follows: data have; length ID $ 10 VariableList $ 50; infile cards dsd dlm='|' truncover ; input ID VariableList; datalines; A1|stringA stringB 123 A2|stringA + stringB > stringC A3|stringA A4|stringB stringC 456 A5|stringC stringD abc ; run; %let matchString=stringA|stringB; data want; set have; where prxmatch("/\b(&matchString.)\b/", VariableList); run; But this would find all the rows that contain stringA and stringB, including the ones that I don't want (A2 & A4). How do I go about excluding them? Thanks a lot!
... View more