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 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 9 Jan 2002 04:55:07 +0000
Reply-To:     sashole@bellsouth.net
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Dorfman <paul_dorfman@HOTMAIL.COM>
Subject:      Re: proc format cntlin=class2; when there are missing values.
Comments: To: myra@DATASQUARE.COM
Content-Type: text/plain; format=flowed

Myra,

The golden rule about other people's code is: Do not trust it until you have tested it and proven it correct. This particular piece is simply rancid. Bob Virgile has already pointed out to one problem with the code you have got from archives: The value of LABEL will always contain but 1 character since the statement

LABEL = " " ;

compiles first. My problem with this code is my own inability to comprehend how the format could have even been compiled. The only possibilty for such a thing to have actually happened is the presence of the variable START in the Class1 file to begin with. Otherwise, Proc Format, expecting *at least* the variables START and LABEL to be available from the CNTLIN= file, would not have compiled the format. If it had not, the only reason for your Data step using the format to have not abended could have been the presence of a dormant format $Vehicle in the FORMATS catalog in the library LIBRARY (provided that it had not been compiled beforehand in the program and hence placed in the FORMATS catalog in the WORK library). And now, the only reason for your format response to have been the same as the argument could have been the absence of the OTHER clause in the compiled format (i.e. a record with HLO = 'O' in its CNTLOUT data set).

Here is how the step writing your Cntlin= file should look like if you need to produce expected results:

data cntlin ; retain fmtname 'vehicle' type 'c' ; do until (eof) ; set class1 (keep=v_id v_type rename=(v_id=start v_type=label)) ; output ; end ; label = ' ' ; hlo = 'O' ; output ; stop ; run ;

Note that if you do not have the V_ID variable in the Class1 file, your format will have no argument to rely upon.

Kind regards, ==================== Paul M. Dorfman Jacksonville, FL ====================

>From: Myra Oltsik <myra@DATASQUARE.COM> >Reply-To: Myra Oltsik <myra@DATASQUARE.COM> >To: SAS-L@LISTSERV.UGA.EDU >Subject: proc format cntlin=class2; when there are missing values. >Date: Tue, 8 Jan 2002 14:24:33 -0800 > >I found the following in the archives: > > DATA CLASS2 ; > if eof eq 1 then do; > LABEL=" "; /* assign a value of blank when no format match >*/ > FMTNAME = '$VEHICLE'; /* additional code */ > HLO="O"; > output ; > end; > SET CLASS1 end=eof; > LABEL = V_TYPE ; > FMTNAME = '$VEHICLE'; > output ; /* additional code */ > RUN ; > > PROC FORMAT CNTLIN=CLASS2 ; > RUN ; > >Don't you need a statement like: > > STATE = "OTHER" > >in the do loop to make it work properly? > >I've used code just like this. But in the data step, when no matching >"start" was found, SAS filled the new field with the value of the >field in the put statement. In the example below, varnew took on the >value of varold instead of being missing. > > DATA NEW; > SET OLD; > VARNEW = PUT(VAROLD,$VEHCILE.); > DROP VAROLD; > RUN; > >How can I prevent this from happening? > >Thanks. >Myra

_________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com


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