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: 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 25. 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
  • 299 views
  • 0 likes
  • 2 in conversation