🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-27-2020 06:45 PM
(6274 views)
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;
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, it worked for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;