Wildcard "if" statement in SAS

How do I check a field in SAS equal to anything with the word "Parent" or "p_"  in the field?
moriniaAdvanced Analytics AnalystAsked:
Who is Participating?
 
bradanelsonCommented:
IF INDEX(fieldname,'Parent') or INDEX(fieldname,'p_') THEN ...
0
 
giltjrCommented:
Not sure about anywhere, but

IF (NAME = :"STR" )

Will match if the field name starts with STR.  I'm not sure you can do something like:

IF (NAME = :"STR":) if it would match if the field name contains "STR" anyplace.
0
 
moriniaAdvanced Analytics AnalystAuthor Commented:
The above solution did not work.
0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
moriniaAdvanced Analytics AnalystAuthor Commented:
I was able to use substring to check for the first csix characters.  I can;t figure out how to check if unknown as to where in the string a particualr subset is.
0
 
moriniaAdvanced Analytics AnalystAuthor Commented:
Bradanelson,

Is index being set in a loop?
0
 
bradanelsonCommented:
I don't understand your last question.  The IF statement I gave will be true if Parent or p_ is anywhere in the value of fieldname.  Replace fieldname with your field and add the statement or statements after the THEN in your code.
0
 
moriniaAdvanced Analytics AnalystAuthor Commented:
It worked fine!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.