Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to find string contain only alphabets in sas

I need to find whether the string is numeric , character or alphanumeric in SAS

String Remarks
ABC Character
ABC123 AlphaNum
1234 Numeric

I tried PRXmatch but its not working

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try this

data have;
input String $;
datalines;
ABC    
ABC123 
1234   
;

data want(drop = a n);
   set have;
   a = anyalpha(string);
   n = anydigit(string);

   if      a and n then     Remarks = 'Alphanum ';
   else if a and not n then Remarks = 'Character';
   else if n and not a then Remarks = 'Numeric  ';
run;

Result:

String  Remarks
ABC     Character
ABC123  Alphanum
1234    Numeric
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading