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 (January 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 7 Jan 2011 13:42:42 -0600
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: The d in w.d informat
Comments: To: "Stehle, James" <James.Stehle@bea.gov>
In-Reply-To:  <14871F0AD125614C96749048C5E67D610454691C@MAILSERV1.BEA.DC>
Content-Type: text/plain; charset=ISO-8859-1

I'll preempt Ron and say RTFM on w.d informat :) http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/a000199348.htm

More seriously though, the W.D input is intended, as I understand it, to allow you to read data that is NOT including a decimal, and force it to have a decimal. So if your data is 234 123 124 515 and it's really dollars and cents, then reading it with the 4.2 informat gives you 2.34 1.23 1.24 5.15 etc.

SAS will normally read the decimal in correctly if it IS placed in the data, unless you ask it to override that by specifying a d in the w.d readin. Using the .d it will literally divide your numbers by that power of 10.

-Joe

On Fri, Jan 7, 2011 at 1:23 PM, Stehle, James <James.Stehle@bea.gov> wrote:

> /* > I want to read a column of data that can be numbers or text > and the numbers sometimes having decimal point and sometimes not. > When I used w.d informat as in input(text,7.2) to convert text to > numeric > I was surprised to find that numbers without decimal place were coverted > > as if they had a decimal place before the second from right digit and > that > number with decimal places still kept their places even the one with 3 > decimal places. > By removing the 2 from the informat everything was converted with their > original decimal places > including the number with no decimal places. > > My question is what is the intent of the d in w.d informat. > > Additionally I wonder why I am getting two Notes "Invalid argument to > function INPUT". > > Thanks. > -Jim > */ > > data mixedDecimal; > length text $ 7; > input text ; > num=input(text,7.); > num2=input (text, 7.2); > num3=text + 0; > cards; > 1111 > 2222.2 > 3333.22 > 444.444 > a > ; > run; > > Proc print;run; > > /* > log and output follow: > 41 data mixedDecimal; > 42 length text $ 7; > 43 input text ; > 44 num=input(text,7.); > 45 num2=input (text, 7.2); > 46 num3=text + 0; > 47 cards; > > NOTE: Character values have been converted to numeric values at the > places given by: (Line):(Column). > 46:6 > NOTE: Invalid argument to function INPUT at line 44 column 5. > NOTE: Invalid argument to function INPUT at line 45 column 6. > NOTE: Invalid numeric data, text='a' , at line 46 column 6. > RULE: > ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- > --+----8----+----9----+----0 > 52 a > text=a num=. num2=. num3=. _ERROR_=1 _N_=5 > NOTE: Missing values were generated as a result of performing an > operation on missing values. > Each place is given by: (Number of times) at (Line):(Column). > 1 at 46:11 > NOTE: Mathematical operations could not be performed at the following > places. The results of the operations have been set to missing values. > Each place is given by: (Number of times) at (Line):(Column). > 1 at 44:5 1 at 45:6 > NOTE: The data set WORK.MIXEDDECIMAL has 5 observations and 4 variables. > NOTE: DATA statement used (Total process time): > real time 1.07 seconds > cpu time 0.01 seconds > > > > The SAS System > 12:21 Friday, January 7, 2011 2 > > Obs text num num2 num3 > > 1 1111 1111.00 11.11 1111.00 > 2 2222.2 2222.20 2222.20 2222.20 > 3 3333.22 3333.22 3333.22 3333.22 > 4 444.444 444.44 444.44 444.44 > 5 a . . . > > */ >


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