BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bayzid
Obsidian | Level 7

Hi,

How can i get SAS to ignore / inside my target text? For example, I want to find the following texts: INDACATEROL and  INDACATEROL/GLYCOPYRRONIUM

when i use the argument pattern_id=prxparse('/(  INDACATEROL| INDACATEROL/GLYCOPYRRONIUM)/i');

it is returning error message because of the "/" inside the parentheses.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You have to MASK or ESCAPE the characters that have special meaning to RegEx by adding a backslash before them.

pattern_id=prxparse('/(  INDACATEROL| INDACATEROL\/GLYCOPYRRONIUM)/i')

Did you really mean to include the spaces at the start of the search strings? What about words that are at the beginning of the string being examined?  And did you really mean to require two spaces before INDCATAROL alone and only one space before INDACATEROL/GLYCOPYRRONIUM?

 

Without that extra space on the first pattern anything that would match the first pattern would also match the start of the second pattern.

 

View solution in original post

5 REPLIES 5
bayzid
Obsidian | Level 7

I don't want to mask it but consider it as a part of my target string. I want SAS to extract it with the slash. For example "CLOTRIMAZOLE/HYDROCORTISONE" is a single word that I want to pick up.

Tom
Super User Tom
Super User

You have to MASK or ESCAPE the characters that have special meaning to RegEx by adding a backslash before them.

pattern_id=prxparse('/(  INDACATEROL| INDACATEROL\/GLYCOPYRRONIUM)/i')

Did you really mean to include the spaces at the start of the search strings? What about words that are at the beginning of the string being examined?  And did you really mean to require two spaces before INDCATAROL alone and only one space before INDACATEROL/GLYCOPYRRONIUM?

 

Without that extra space on the first pattern anything that would match the first pattern would also match the start of the second pattern.

 

bayzid
Obsidian | Level 7

I inserted a space at the beginning of the character variable. Now it's working.
Thanks to both of you.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 812 views
  • 0 likes
  • 3 in conversation