|
Howard
I'm quite unhappy about the too-tolerant informats commaX and comma
In this (v8.1) log clip, see 123.456,789 and 123,456.789
279 %put %sysfunc( inputn( %nrstr( 123,456.789), comma32 ));
123456.789
280 %put %sysfunc( inputn( %nrstr( 123,456.789), commaX32 ));
123.456789
281 %put %sysfunc( inputn( %nrstr( 123.456,789), comma32 ));
123.456789
282 %put %sysfunc( inputn( %nrstr( 123.456,789), commaX32 ));
123456.789
OK, perhaps we should always know whether to use the -X version........
but, it might be reasonable to reject a value with two decimal points !
Regards
Peter Crawford
Datum: 18/11/2002 20:01
An: SAS-L@LISTSERV.UGA.EDU
Antwort an: Howard_Schreier@ITA.DOC.GOV
Betreff: Re: Is a variable Numeric?
Nachrichtentext:
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
--
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
|