Date: Mon, 18 Nov 2002 14:01:19 -0500
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
Subject: Re: Is a variable Numeric?
Content-Type: text/plain; charset=ISO-8859-1
A couple of points, based on reading the documentation:
There is no BEST informat. I find that reasonable, since the concept would
require knowing the numeric magnitude in order to derive the numeric
magnitude. Apparently, SAS accepts code using BEST as an informat and
interprets it as a simple width-only informat.
The COMMA informat accepts and ignores a fair amount of arbitrary junk in a
field (commas, blanks, dollar signs, percent signs, non-leading minus signs,
and right parentheses). So if a particular string passes the test using a
COMMA informat, you know that it can be converted using the COMMA informat,
but you are not assured of much else. If you need to validate for use with
other software, you would not want to rely on it.
On Mon, 18 Nov 2002 17:08:59 +0000, Paul Dorfman <paul_dorfman@HOTMAIL.COM>
>From: "roland.rashleigh-berry" <roland.rashleigh-berry@NTLWORLD.COM>
>>"גדי בן אבי" <GADI_B@MALAM.COM> wrote in message
>>Q: How do I check if a variable is numeric?
>>A: You can use the "vartype()" function.
>Vartype() queries a data set or view descriptor, hence it will not work
>non-descriptor variables. VTYPE(variable-name), though, is in this sense
>universal and much easier to use, for it does not require a data set ID and
>simply returns N or C depending on the variable type.
>>Q: How do I check if a text variable has numeric content (only digits, >a
>>period and a sign)?
>>A: if compress(var,'0123456789.+-') EQ ' ' then...
>This will work as well as Verify(), as Peter has suggested. However,
>methinks the spirit of the original quesiton implied that the order of
>characters in the string would matter in that it should form a valid
>number. Thus would rather second your subsequent suggestion of using an
>informat, such as best32. or comma32. depending on the specific characters
>to be detected.
>Paul M. Dorfman
>The new MSN 8: advanced junk mail protection and 2 months FREE*