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 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 28 Nov 2006 13:06:56 -0500
Reply-To:     Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject:      Re: Help: The Input function and a format:
In-Reply-To:  <200611281754.kASH915l007017@mailgw.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

As an addendum to Howard's recommendation, make sure that the numeric variables are stored as length 8 rather than something shorter, both in the data set fed to PROC FORMAT and in your "main" data set (assuming that in real life you're not just reading in cards as in your example).

It's also worth noting the log messages in Roland's previous response. What goes into an informat is by definition always character, not numeric.

If all else fails, and assuming your original values are all between 0 and 1 with 5 decimal places, try integerizing (is that a word?) everything:

proc format; ... '81456'-<'81562' = 1001 etc.

then in your DATA step:

CBR_MEND = input(put(CBR_test*100000,z5.),mapf.);

Mike Rhoads Westat RhoadsM1@Westat.com

-----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Howard Schreier <hs AT dc-sug DOT org> Sent: Tuesday, November 28, 2006 12:55 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Help: The Input function and a format:

On Tue, 28 Nov 2006 09:21:14 -0800, tanwan <tanwanzang@YAHOO.COM> wrote:

>I can't replicate this with contrived data but this is what is >happening. > >I have a format and am using the input function like: > >proc format; >invalue mapf >other=9999 >0.81456-<0.81562=1001 >0.81562-<0.81599=1002 >0.81599-<0.81612=1003 >; > >data temp; >input CBR_test; >CBR_MEND=input(CBR_test, mapf.); >cards; >0.81612 >0.81562 >0.81606 >0.74154 >0.81455 >0.81456 >;run; > >I actually create the mapf format from a data set and Proc format's >ctlin. I have several hundred classifications and I can not hard-code >all of them. > >PROBLEM: My problem is that some (a few) CBR_MENDs are put in the wrong >categories, especially if CBR_test falls on the boundary of the format >range. E.g. for CBR_test = 0.81562 (which is on the boundary), >CBR_MEND may return as 1001, when actually it should be 1002. > >Any help will be greatly appreciated. > >Tanwan

Look into the FUZZ= option for your INVALUE statement. If that does not do it, you may have to apply the ROUND function to the boundary values in the CNTLIN= data set and/or to the CBR_MEND values.


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