BookmarkSubscribeRSS Feed
waw_pie
Calcite | Level 5

Hey,
how can i do this LIKE '[^A-D][^A-Z][^A-Z][^0-9]%' in SAS?
I want to leave only those cases that do not have the letters A to D in the first place, the letters A to Z in the second and third places and the numbers 0 to 1 in the fourth place.
Sample data below:

FU321007
18AC90104
ACZ879876
15BA10226
18AC77472
CSR646689
AA9601648
AAA655447

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Hi and welcome to the SAS Community.

 

You can do something like this

 

data have;
input string $10.;
datalines;
FU321007
18AC90104
ACZ879876
15BA10226
18AC77472
CSR646689
AA9601648
AAA655447
;

data want;
    set have;
    if not prxmatch('/^[A-D][A-Z]{2}[0-9]/', string);
run;
pau13rown
Lapis Lazuli | Level 10

index or substr functions with an "if ... then delete" statement. That would be a crude way, i think there's a better way using other text functions that someone else will know

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
  • 2 replies
  • 1393 views
  • 2 likes
  • 3 in conversation