BookmarkSubscribeRSS Feed
user112a2
Obsidian | Level 7

I have a question on the below code.
Where it has \s\S\S$, is this looking for something like: " NJ$"? I have not seen \S$. Unless, this is an actual dollar sign in the string.

Also, in the ^.*(\s\S\S$).*$/$1. Is this looking at beginning of string for something like: " NJ$"? I'm not sure what the .*$/$1 is doing. I am new to regex in SAS.

Removed

 

1 REPLY 1
PGStats
Opal | Level 21

$ matches the end of the string. I guess this is looking for strings that end with a space followed by two non-space characters. If match, then extract those two characters to string claim_state and remove them from the string. It could be done with:

 

if prxmatch('/\s\S\S$/', strip(claim_txn_merchant_clean)) then do;
    claim_temp = strip(claim_txn_merchant_clean);
    drop claim_temp;
    claim_state = substr(claim_temp, length((claim_temp)-1, 2);
    claim_txn_merchant_clean = substr(claim_temp, 1, length(claim_temp)-3);
    end;
PG

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 708 views
  • 0 likes
  • 2 in conversation