|
On Mon, 16 Oct 2000 16:19:49 GMT, Brian Shore <bgs50@HOTMAIL.COM> wrote:
>Hi,
>
>Is there a way in SAS to determine if a character variable contains all
>alphabetic data? For example, I read a var called ACCOUNT and I want to
>know if the account number contains all alphabetic data. In some languages
>(C, SQL?), there is a function called ISALPHA() that does this, but I don't
>know of any such function in SAS.
>
>thanks
>_________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>Share information about yourself, create your own public profile at
>http://profiles.msn.com.
In SAS you can use the verify function for that:
data test;
a="skjdhkj 1";
rc=verify(upcase(a),"ABCDEFGHIJKLMNOPQRSTUVWXYZ ");
put rc=;
run;
This is much more flexible, because you can use your own definition, what
is "alpha" (is $ alpha or not?). The second string contains all chars which
you will allow. If you have a char in a which is not in the string, you
will get the position of the unallowed char in a, or lets say "true". So
you can use:
if not verify ...
verify returns "false" if the string only contains allowed chars.
|