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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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