Date: Tue, 6 Jan 2004 08:34:12 -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: Odd format behavior and workaround
Content-Type: text/plain
Well, it never ceases to amaze me how much you can learn from one thread,
even after 20+ years SAS experience! ;-)
In the first place, I had never encountered the error that Jeff originally
ran into.
I had also never thought to use a character START variable in order to get
the 'OTHER' record into the CNTLIN data set for PROC FORMAT. Even after
seeing Jeff's post I was somewhat skeptical that it was producing the
intended results, but a run of PROC FORMAT with the FMTLIB option and
rerunning Jeff's original data step and PROC PRINT served to convince me.
You can, however, also do this while still keeping the START variable
numeric. Assign a value of 'O' (the letter, not a zero) to the special
variable HLO to indicate that the label applies to "other" values, leaving
it blank on other records. (You can also use several other coded letters in
this field; see the SAS documentation for details.)
data work.makefmt;
type='N';
fmtname='TEST';
start=9165551212; label='Y'; hlo=' '; output;
start=.; label='N'; hlo='O'; output;
run;
Mike Rhoads
Westat
RhoadsM1@Westat.com
-----Original Message-----
From: Jeff Voeller [mailto:c-jeff.voeller@MCI.COM]
Sent: Monday, January 05, 2004 5:55 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Odd format behavior and workaround
Jack:
You're absolutely right, that eliminated the message. It also explained why
I still got the results I expected even with the message. And it looks a
lot less...well, stupid...than coding ' Y'!
I strongly agree with you about the utility of "other", especially with
character formats. I hadn't done it in this case because the real program
(obviously I posted only a simplified excerpt) created the format via a
CNTLIN dataset with a numeric START variable. Makes it difficult to append
a final record with 'other' as the value in the same variable!
Though typing the above just made me want to try another test:
/* Begin */
data work.makefmt;
type='N';
fmtname='TEST';
start='9165551212'; label='Y'; output;
start='other'; label='N'; output;
run;
proc format library=work cntlin=work.makefmt;
run;
/* End */
It works just fine--the START variable does *not* have to be numeric to
"feed" a numeric format, as long as a TYPE of "N" is explicitly specified.
(Again I hear everyone else chanting "Well, duh!")
Thanks,
Jeff
<snip>