LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext 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 14:01:45 -0000
Reply-To:   "roland.rashleigh-berry" <roland.rashleigh-berry@NTLWORLD.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "roland.rashleigh-berry" <roland.rashleigh-berry@NTLWORLD.COM>
Organization:   ntlworld News Service
Subject:   Re: Is a variable Numeric?

verify() is also good.

You would maybe be better off using input(var,?? comma32.) rather than "best" since it will also accept good numbers with the comma notation such as 12,123.08 but what you suggest is an improved method.

"Peter Crawford" <peter.crawford@DB.COM> wrote in message news:OF5473CF6A.26298DB3-ON41256C75.00354FC2@db.com... > Hi Roland > > had you considered the verify function ? > posn_not_in_list = verify( source_var, '0123456789.+.' ); > Of course, many "numeric" informats allow non-numeric chars > like the letters D, E and perhaps others ($) . > > However, I think the verify() function was designed > for the purpose of detecting "non-standard" characters > in a string....... like this posters question > ..... > and however, I'm not sure about the point of such > validation, over the more informative > value = input( var, ?? best32. ); > as it also provides the actual value, when present...... > and is less likely to accept -12--+-45+.+78. > as in > 134 data; > 135 do source_var= '-12--+-45+.+78.' > 136 , '1234567890.1234' > 137 , '1234567890'; > 138 posn_not_in_list = verify( source_var, '1234567890.+-' ); > 139 value = input( source_var, ?? best32. ); > 140 put (_all_ )(=); > 141 end; > 142 run; > > source_var=-12--+-45+.+78. posn_not_in_list=0 value=. > source_var=1234567890.1234 posn_not_in_list=0 value=1234567890.1 > source_var=1234567890 posn_not_in_list=11 value=1234567890 > NOTE: The data set.................... > > Regards > Peter Crawford > > > Datum: 18/11/2002 10:39 > An: SAS-L@LISTSERV.UGA.EDU > > > > > Antwort an: "roland.rashleigh-berry" <roland.rashleigh-berry@NTLWORLD.COM> > > Betreff: Re: Is a variable Numeric? > Nachrichtentext: > > "âãé áï àáé" <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. > > 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... > > > > > > -- > > 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