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 (February 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 13 Feb 2008 17:34:28 -0500
Reply-To:   Ya Huang <ya.huang@AMYLIN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Ya Huang <ya.huang@AMYLIN.COM>
Subject:   Re: question about input()
Comments:   To: Mark Terjeson <Mterjeson@RUSSELL.COM>

Mark gave a good explanation on why you shouldn't have used input function for numeric var. But he didn't explain why you get c=missing. Here is why:

c=input(a, 3.1); is equivelent to c=input(put(a,best12.),3.1); which is the same as c=input(' 1',3.1); since it is right justified, 3.1 is not enough to get the correct number what you really need is to left justify first, like c=input('1 ',3.); or c=input(put(a,best12.-l),3.); or c=input(put(a,best.),12.);

On Wed, 13 Feb 2008 14:16:53 -0800, Terjeson, Mark <Mterjeson@RUSSELL.COM> wrote:

>Hi Mindy, > >The INPUT function converts string to numeric. >The PUT function converts numeric to string. > >e.g. > > myString = put(expecting_numeric,format) > myNumeric= input(expecting_string,informat) > > >in your code > c=input(a, 3.1); >if a is already a numeric and you use input(), >it is expecting a string argument so the numeric >'a' variable is converted to string first before >performing the INPUT() function. > >It looks like you already know that 'a' is numeric >and if you are wanting to convert it to string 'c' >then use the PUT() function instead. > > > > >Hope this is helpful. > > >Mark Terjeson >Senior Programmer Analyst, IM&R >Russell Investments > > >Russell Investments >Global Leaders in Multi-Manager Investing > > > > > > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Mindy >Sent: Wednesday, February 13, 2008 2:07 PM >To: SAS-L@LISTSERV.UGA.EDU >Subject: question about input() > >Hey guys, > >I have a question about input() ___ maybe related with format/ >informat. > >Below is sample code: > > data try; > input a; > cards; > 1 > ; > run; > data try; > set try; > c=input(a, 3.1); > run; > proc contents; run; > proc print; run; > >And I got note as > >20 set try; >21 c=input(a, 3.1); >22 run; > >NOTE: Numeric values have been converted to character values at the >places given by: (Line):(Column). > 21:12 > >Output of proc contents as > >--Alphabetic List of Variables and Attributes----- > > # Variable Type >Len Pos > >??????????????????????????????????? > 1 a Num >8 0 > 2 c Num >8 8 > >Output of proc print as > > Obs a c > > 1 1 . > > >I don't understand why I get the note and missing value of c, which I >thought it should be 1.0 > >Many thanks. > >MIndy


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