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 (October 1997, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 7 Oct 1997 00:53:05 GMT
Reply-To:     EMWalczak <emwalczak@AOL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         EMWalczak <emwalczak@AOL.COM>
Organization: AOL http://www.aol.com
Subject:      Re: charecter to numeric conversion

I stand corrected!! Apparently I have always renamed the variable, and it just slipped my mind totally!

The code I have used is : newvar=charx*1; And someone pointed out to me that newvar=charx+0; would be faster. But either way, i AM creating a new variable, and not changing the orginal, as orginally stated.

sorry for the confusion!! I have done this so often, I can't believe i've posted it incorrectly here on SAS-L!!! Sorry all! Ellen Walczak

Subject: Re: charecter to numeric conversion >From: "Seltzer, Jon D." <SeltzerJD@PHIBRED.COM> >Date: Mon, Oct 6, 1997 10:45 EDT >Message-id: ><c=US%a=_%p=PHIBRED%l=ATLAS-971006144511Z-19793@orion.phibred.com> > >I do not understand what you are saying. I thought the original problem >was: Can you convert a character variable to numeric with the same name. > Your code below will not do that. I am interested in what you are >doing, but I do not understand what you are doing. Can you provide an >example? Some test code with a log would be very helpful. > >Are you saying the below your code: >>Data test;set test; >> charx=charx*1; >>run; > >will now define the variable charx as numeric and that you can use proc >means on the variable 'charx', where proc means treats the variable >'charx' as numeric instead of character? I actually believe you are NOT >saying this since I tried it and it does not work. With that in mind >can you please give an example. >Seltzers Monthly predictions: >Yes: Some of the time. > >Seltzers profound mathematical conclusion of the month: >If you say the words 'New' 'Miracle' real fast your saying the word >'Numerical'!!!!! Wow! > >>---------- >>From: EMWalczak[SMTP:emwalczak@AOL.COM] >>Sent: Saturday, October 04, 1997 3:56 PM >>To: SAS-L@VM.MARIST.EDU >>Subject: Re: charecter to numeric conversion >> >>but it still works, if you are working with a dbase that has defined a >>variable >> you need as char, but you want to run a proc means SAS lets you do it! >>Data test;set test; >> charx=charx*1; >>run; >> >>or even better do charx=charx+0; >>it may not change the charx variable to numeric but it sure gets the job >done >> in alot less code. >> >>>Subject: Re: charecter to numeric conversion >>>From: "Seltzer, Jon D." <SeltzerJD@PHIBRED.COM> >>>Date: Fri, Oct 3, 1997 18:28 EDT >>>Message-id: >>><c=US%a=_%p=PHIBRED%l=ATLAS-971003222802Z-18692@orion.phibred.com> >>> >>>The below code DOES NOT convert a character variable to a numeric >>>variable with the same name for the data set when using SAS 6.12 on an >>>Apha VAX. >>> >>>>DATA new ; >>>> SET OLD; >>>>CHARVAR=CHARVAR*1; >>> RUN >>> >>>I was surprised when this claim was made. I thought maybe SAS had been >>>modified. Perhaps another version has that I do not know about. >>> >>>Here is an example from a test log file: SAS first convert the >>>character values to numeric(The first NOTE) and then takes the numeric >>>values and converts them back to character(The second NOTE). >>> >>>12 >>>13 data test; >>>14 set test; >>>15 charx=charx*1; >>>16 run; >>> >>>NOTE: Character values have been converted to numeric values at the >>>places given by: (Line):(Column). >>> 15:10 >>>NOTE: Numeric values have been converted to character values at the >>>places given by: (Line):(Column). >>> 15:15 >>> >>>With the rename command you can do it; >>> >>>data it(rename=(varnum=varchar)); >>> set it; >>> varnum=varchar+0; >>> *or varnum=varchar*1; >>> drop varchar; >>>run; >>> >>> >> > > > > > > >


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