BookmarkSubscribeRSS Feed
yashpande
Obsidian | Level 7
Hi,

I have below values in datset


Or
OR-
A OR B
AND+
and
Or-
ELSE
1ELSE

WHAT I want is out put as below



OR-
AND+
Or-
1ELSE

So Basically if there is any digit or expression just immediately after SAS reserved keywords then it should be selected and this needs to be done using Prxchange regular expression as then it would be feed off to another third-party tool hence a prxchange regex is must

I am completely out of ideas as I haven't used regex before

Any help is really appreciated
1 REPLY 1
Ksharp
Super User
data have;
input x $20.;
cards;
Or
OR-
A OR B
AND+
and
Or-
ELSE
1ELSE
;

data want;
 set have;
 want=prxchange('s/^[a-z]+$//i',-1,compress(x));
run;

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