BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
abx
Fluorite | Level 6 abx
Fluorite | Level 6
Hi All. Need help on prxmatch function.

Can i know how do i use prxmatch function to identify first two alphabets of these group of customer name?

Needed to identify:-

1. Name starts with A and follow by a space will need to group as “A”. Example: A Academy Ltd
2. Any Name starts from AA to AC
will need to group as “AA-AC”. Example: AA Bookstore Pte Ltd, ABC Partnership, Academy Holding
3. Any name starts from AD to AF will need to group as “AD-AF”. Example: Affluent Circle Ltd, Adam James Smith.

Thank you for helping.
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
input x $80.;
length group $ 20;
if prxmatch('/^A\s+/i',left(x)) then group='A';
if prxmatch('/^A[A-C]/i',left(x)) then group='AA-AC';
if prxmatch('/^A[D-F]/i',left(x)) then group='AD-AF';
cards;
A Academy Ltd
AA Bookstore Pte Ltd, ABC Partnership, Academy Holding
Affluent Circle Ltd, Adam James Smith.
;

View solution in original post

1 REPLY 1
Ksharp
Super User
data have;
input x $80.;
length group $ 20;
if prxmatch('/^A\s+/i',left(x)) then group='A';
if prxmatch('/^A[A-C]/i',left(x)) then group='AA-AC';
if prxmatch('/^A[D-F]/i',left(x)) then group='AD-AF';
cards;
A Academy Ltd
AA Bookstore Pte Ltd, ABC Partnership, Academy Holding
Affluent Circle Ltd, Adam James Smith.
;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 384 views
  • 1 like
  • 2 in conversation