data have;
text = "The quick brown fox jumps over 23 lazy dogs.(1-27) The quick brown-fox jumps over the lazy dog.(28)";
run;
data want;
set have;
text2 = compress(text,"()-1234567890");
run;
You can try to use a pearl regular expression:
data want;
set have;
text2=prxchange('s/\([\d-]+\)//i', -1, text);
run;
This looks for the pattern \([\d-]+\) in the variable 'text' as many times as needed (second argument = -1)
\([\d-]+\) = a parenthesis followed by one or more digits or hyphens followed by a parenthesis.
You can try to use a pearl regular expression:
data want;
set have;
text2=prxchange('s/\([\d-]+\)//i', -1, text);
run;
This looks for the pattern \([\d-]+\) in the variable 'text' as many times as needed (second argument = -1)
\([\d-]+\) = a parenthesis followed by one or more digits or hyphens followed by a parenthesis.
You're welcome @NewSASPerson !
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 25. Read more here about why you should contribute and what is in it for you!
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.