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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 712 views
  • 0 likes
  • 5 in conversation