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 (July 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 11 Jul 2007 20:34:20 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: Convert from Character to Numeric
Comments: To: rndivo@GMAIL.COM
In-Reply-To:  <f1df4bab0707110812y5fb37d5dk44ecf1c3043b3cae@mail.gmail.com>
Content-Type: text/plain; format=flowed

Richard ,

You missed the point.

SAS has two types of variables Numeric and Character and you cant change one on th efly, you have rename it and then apply the value to another variable whos type is in your case numeric. Now once you get to that point you have three options:

1.) Do an Assignment statement and have SAS do a implicit conversion 2.) Multiply by 1 and SAS will do an implicit conversion first. 3.) USe the right freakin informat to start with.

1 and 2 can leave you with nasty little note sin your log which at some shops arent allowed. Secondly they can sometimes screw up on the conversion.

3.) Now three is the best method because you the programmer are explicitly converting it hopefully you have done so correctly, never the less the onus is on the programmer and not left up to SAS to guess. Dates and Times can be a tricky thing while you cxan have some which are all numeric 20071228, simply making them numeric isnt going to accomplish anything more than leaveing them as a character. In fact it will eat up more space. If you use the correct informat SAS will translate these into a numeric which has meaning in SAS. Thus you are now able to use a SAS defined format or user defined format to express it in many different human readbale forms in your output.

Toby Dunn

If anything simply cannot go wrong, it will anyway. Murphys Law #2.

The buddy system is essential to your survival; it gives the enemy somebody else to shoot at. Murphys Law #

Tell a man there are 300 billion stars in the universe and he'll believe you. Tell him a bench has wet paint on it and he'll have to touch to be sure. Murphys Law #9

From: Richard Ndivo <rndivo@GMAIL.COM> Reply-To: Richard Ndivo <rndivo@GMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Convert from Character to Numeric Date: Wed, 11 Jul 2007 18:12:42 +0300

Hi All, Still on the subject of converting from character to numeric; which is more efficient: multiplying the variable by 1 (var2 = var1 * 1); or using the input function (var2 = input(var1, x.);

Thanks.

On 6/29/07, toby dunn <tobydunn@hotmail.com> wrote: > >USe the right informat, yymmdd > > > >Toby Dunn > >If anything simply cannot go wrong, it will anyway. Murphys Law #2. > >The buddy system is essential to your survival; it gives the enemy >somebody >else to shoot at. >Murphys Law # > > >Tell a man there are 300 billion stars in the universe and he'll believe >you. Tell him a bench has wet paint on it and he'll have to touch to be >sure. Murphys Law #9 > > > > > > >From: Job Seeker <entry_mid_level_sas@YAHOO.COM> >Reply-To: Job Seeker <entry_mid_level_sas@YAHOO.COM> >To: SAS-L@LISTSERV.UGA.EDU >Subject: Convert from Character to Numeric >Date: Fri, 29 Jun 2007 14:19:46 -0400 > >Trying to Convert from Character to Numeric. Can anyone please let me know >what may be possible wrong with the following coding: > > format birthdtn DATE9.; > birthdtn=input(compress(birthdt, '-'), date9.); > > >Getting following error: >NOTE: Invalid argument to function INPUT at line 2308 column 14. >SUBJID=0020033 SEX=Female BIRTHDT=19610424 birthdtn=. _ERROR_=1 _N_=1 >NOTE: Invalid argument to function INPUT at line 2308 column 14. >SUBJID=0020033 SEX=Female BIRTHDT=19610424 birthdtn=. _ERROR_=1 _N_=2 >NOTE: Invalid argument to function INPUT at line 2308 column 14. > >Thank you. > >_________________________________________________________________ >Hotmail to go? Get your Hotmail, news, sports and much more! >http://mobile.msn.com >

_________________________________________________________________ http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_2G_0507


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