data have;
input names$;
cards;
12345a
1653537d
14252d
425f52a
58463e
run;
this is data i have,but i want only data having 5digits and 1char
i want data like this from above data
12345a
14252d
58463e
code and explanation please?
You can use the PRXMATCH function for example:
data want;
set have;
if prxmatch('/^\d{5}[a-z]$/',strip(names)) then output;
run;
It looks for the following pattern: ^\d{5}[a-z]$
^ = beginning of the string
\d{5} = 5 digits
[a-z] = one letter (case insensitive -> cf "i" modifier)
$ = end of the string
strip() enables to take into account trailing blanks.
You could also use:
if prxmatch('/^\d{5}[a-z]\s*$/i',names) then output;
-> \s means a blank and * means 0,1 or more times -> looks for trailing blanks
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!
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.