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 14:30:50 +0100
Reply-To:     Peter Crawford <peter.crawford@DB.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Crawford <peter.crawford@DB.COM>
Subject:      Re: proc format cntlin=class2; when there are missing values.
Comments: To: Myra Oltsik <myra@DATASQUARE.COM>
Content-type: text/plain; charset=iso-8859-1

Hi Myra

Others have cautioned about using such code (let me describe it as "old"). And about that I agree.

But you asked a "Don't you need........." question to which the answer here is - NO !!

When the variable HLO contains "O" the values in the range variables (start and end) are ignored.

When HLO is left blank (or the column is not provided in the cntlin data set), using START='**OTHER**' does not achieve the effect of HLO='O'. "start='**OTHER**'" provides just another range .

Here is a demo 165 data cntl; 166 retain fmtname '$truble' ; 167 do star = 1 to 5; 168 start = put( star, 16.-L ); 169 label = put( star, words20.-L ); 170 output; 171 end; 172 start='**OTHER**'; 173 LABEL='CRAZY'; 174 OUTPUT; 175 STOP; 176 run;

NOTE: The data set WORK.CNTL has 6 observations and 4 variables. NOTE: DATA statement used: real time 0.06 seconds cpu time 0.03 seconds

177 proc format cntlin=cntl ; NOTE: Format $TRUBLE has been output. 178 run;

NOTE: PROCEDURE FORMAT used: real time 0.04 seconds cpu time 0.01 seconds

NOTE: There were 6 observations read from the data set WORK.CNTL.

179 %put demo of $truble. ; demo of $truble. 180 %put 2 %sysfunc( putc( 2, $truble )); 2 two 181 %put O %sysfunc( putc( O, $truble )); O O 182 %put ? %sysfunc( putc( **OTHER**, $truble )); ? CRAZY

And here is similar logic, but using HLO='O' instead of start='**OTHER**';

183 data cntl; 184 retain fmtname '$truble' ; 185 do star = 1 to 5; 186 start = put( star, 16.-L ); 187 label = put( star, words20.-L ); 188 output; 189 end; 190 hlo ='O'; 191 LABEL='CRAZY'; 192 OUTPUT; 193 STOP; 194 run;

NOTE: The data set WORK.CNTL has 6 observations and 5 variables. NOTE: DATA statement used: real time 0.06 seconds cpu time 0.03 seconds

195 proc format cntlin=cntl ; NOTE: Format $TRUBLE is already on the library. NOTE: Format $TRUBLE has been output. 196 run;

NOTE: PROCEDURE FORMAT used: real time 0.01 seconds cpu time 0.01 seconds

NOTE: There were 6 observations read from the data set WORK.CNTL.

197 %put demo of $truble. ; demo of $truble. 198 %put 2 %sysfunc( putc( 2, $truble )); 2 two 199 %put O %sysfunc( putc( O, $truble )); O CRAZY 200 %put ? %sysfunc( putc( **OTHER**, $truble )); ? CRAZY

Regards Peter Crawford

Datum: 08/01/2002 22:34 An: SAS-L@LISTSERV.UGA.EDU

Antwort an: Myra Oltsik <myra@DATASQUARE.COM>

Betreff: proc format cntlin=class2; when there are missing values. Nachrichtentext:

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

--

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


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