BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Shradha1
Obsidian | Level 7
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?
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Use the Anyalpha Function like this

 

data have;
input s $;
datalines;
12345 
abc12
12abc
23456
;

data want;
   set have;
   if anyalpha(s);
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Use the Anyalpha Function like this

 

data have;
input s $;
datalines;
12345 
abc12
12abc
23456
;

data want;
   set have;
   if anyalpha(s);
run;
BrahmanandaRao
Lapis Lazuli | Level 10
Provide data
rudfaden
Lapis Lazuli | Level 10

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1072 views
  • 0 likes
  • 5 in conversation