Date: Mon, 18 Nov 2002 14:01:19 -0500
Reply-To: Howard_Schreier@ITA.DOC.GOV
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard_Schreier@ITA.DOC.GOV
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>
wrote:
>From: "roland.rashleigh-berry" <roland.rashleigh-berry@NTLWORLD.COM>
>
>>"גדי בן אבי" <GADI_B@MALAM.COM> wrote in message
>>news:B3A415965C0CBC46AE5D76C9B90166AD215C96@jer-mailbox1.jer.ad.malam.com.
..
>>Hi all,
>>
>>Q: How do I check if a variable is numeric?
>>
>>A: You can use the "vartype()" function.
>
>Roland,
>
>Vartype() queries a data set or view descriptor, hence it will not work
for
>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
decimal
>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.
>
>Kind regards,
>-----------------------
>Paul M. Dorfman
>Jacksonville, FL
>-----------------------
>
>
>_________________________________________________________________
>The new MSN 8: advanced junk mail protection and 2 months FREE*
>http://join.msn.com/?page=features/junkmail
|