LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 18 Nov 2002 21:47:30 +0100
Reply-To:   Peter Crawford <peter.crawford@DB.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Peter Crawford <peter.crawford@DB.COM>
Subject:   Re: Is a variable Numeric?
Comments:   To: Ed Heaton <EdHeaton@westat.com>
Content-type:   text/plain; charset=iso-8859-1

Mea Culpa.................................... and my apologies to any lurkers who may still give me credit !

Thank you to Ed Heaton........ who has shown my foot is still even bigger than my mouth !

I had intended showing the difference between commaXw. and commaW.

Here is a much more sufficient demo................ Given a value like 123,456,789.126 i,e, 123.456.789,126 in european notation (the commaXw. style)

Try reading the value with both commaXw. and commaW.

Now it proves that the informats won't accept more than one decimal separator

21 %put %sysfunc( inputn( %str( 123,456,789.126), comma32 )); 123456789.126 22 %put %sysfunc( inputn( %str( 123,456,789.126), commaX32 )); WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is missing or out of range. NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set to a missing value. . 23 %put %sysfunc( inputn( %str( 123.456,789.126), comma32 )); WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is missing or out of range. NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set to a missing value. . 24 %put %sysfunc( inputn( %str( 123.456.789,126), commaX32 )); 123456789.126

Note below, that input strings with only one "thousand separator" will be read successfully by both X and non-X comma informats and with results a thousand times different !

Regards to the everwatchful -L

Peter Crawford

Datum: 18/11/2002 21:25 An: Peter Crawford/Zentrale/DeuBaExt@Zentrale

Betreff: RE: Is a variable Numeric? Nachrichtentext:

Peter, which value has two decimal points? and how did you get this code to run without the dot at the end of your format name? E.g., "comma32."

Ed

-----Original Message----- From: Peter Crawford [mailto:peter.crawford@DB.COM] Sent: Monday, November 18, 2002 2:23 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Is a variable Numeric?

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 >----------------------- > > >_________________________________________________________________

--

--

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.


Back to: Top of message | Previous page | Main SAS-L page