I need to know the observations where var1 starts with a number and var2 starts with a letter. Can someone please help me with the code.
Here is my sample data.
Thanks,
DATA have; INPUT var1 $10. var2 $10.; DATALINES; A153C254 BBF 3 Cuort 5nng 4hhg r4ee5 B124 CC8 0564 1DD 15D48 FF na 3N2 w853 55K run;
What do you expect the result to look like when digit or letter is found in the first position?
The functions ANYDIGIT, ANYLOWER or ANYUPPER may help depending on your desired output.
If ANYDIGIT(var1) = 1 then var1 starts with a digit for example.
View solution in original post
Alternatively..
DATA have; INPUT var1 $ 1-8 var2 $ 10-14; DATALINES; A153C254 BBF 3 Cuort 5nng 4hhg r4ee5 B124 CC8 0564 1DD 15D48 FF na 3N2 w853 55K ; data want; set have; if prxmatch('/^\d.*/', var1) & prxmatch('/^[a-zA-Z].*/', var2); run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Register now!
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.