🔒 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 03-16-2021 06:12 AM
(804 views)
I have a list of strings which contain both alphabets and numericals.
I want to keep only those strings which contain only alphabets or a combination of alphabets and numerics. I want to remove strings which contain only numericals. How do I achieve this?
I want to keep only those strings which contain only alphabets or a combination of alphabets and numerics. I want to remove strings which contain only numericals. How do I achieve this?
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the Anyalpha Function like this
data have;
input s $;
datalines;
12345
abc12
12abc
23456
;
data want;
set have;
if anyalpha(s);
run;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the Anyalpha Function like this
data have;
input s $;
datalines;
12345
abc12
12abc
23456
;
data want;
set have;
if anyalpha(s);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Provide data
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the ANYDIGIT function:
data have;
input string $10.;
datalines;
abc
defg
abc12de
;
data want;
set have;
where anydigit(string) = 0;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try regex
data have;
input string $10.;
datalines;
asd123ffgg
sdffggghhj
34fggghhhh
dfvd
dvrfgbbfe1
;
run;
data want;
set have;
pattern="s/\d+/$1/";
patternid=prxparse(pattern);
if not prxmatch(patternid,string) then do;
output;
end;
run;