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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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