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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.