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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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
  • 1219 views
  • 0 likes
  • 5 in conversation