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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 231 views
  • 0 likes
  • 2 in conversation