Date: Mon, 5 Jan 2004 15:26:23 -0700
Reply-To: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Subject: Re: Odd format behavior and workaround
Content-Type: text/plain; charset=us-ascii
Try this instead:
=====
proc format library=work;
value test 9165551212='Y'
other = 'N';
run;
=====
If you don't specify an other value, SAS will attempt to return the
original value (frequently a gotcha, so it's a good idea to always code
an other value). My guess is that in your code SAS is trying to put
into a space that's too small to hold it, and that's why you're getting
the error messages.
--
JackHamilton@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA
>>> "Jeff Voeller" <c-jeff.voeller@MCI.COM> 01/05/2004 1:54 PM >>>
I've been getting what seems like a spurious format-related error
message.
I've found a reasonably easy workaround, but thought I would post this
here
just because I find it a bit curious. (SAS 8.2, Z/OS, same behavior in
interactive or batch mode.)
When I submit this code:
/* Begin */
proc format library=work;
value test 9165551212='Y';
run;
data work.hello;
format phone 10.;
phone=9165551212; output;
phone=5035551212; output;
run;
proc print data=work.hello;
where put(phone,test.)='Y';
run;
/* End */
The PROC PRINT step writes these messages to the log:
ERROR: PUT/INPUT function reported 'ERROR: Invalid value for width
specified - width out of range' while processing WHERE clause.
NOTE: There were 1 observations read from the data set WORK.HELLO.
WHERE PUT(phone, TEST1.)='Y';
NOTE: At least one W.D format was too small for the number to be
printed.
The decimal may be shifted by the "BEST" format.
Despite this, I get the results I expect (i.e., the only number to
print is
9165551212). But...hmm...the TEST. format is being referred to as
"TEST1.".
The workaround (well, *a* workaround) to avoid the message is to write
the
code as:
/* Begin */
proc format library=work;
value test 9165551212=' Y';
run;
data work.hello;
format phone 10.;
phone=9165551212; output;
phone=5035551212; output;
run;
proc print data=work.hello;
where put(phone,test.)=' Y';
run;
/* End */
This avoids the nasty red ERROR: message, but check this out:
NOTE: There were 1 observations read from the data set WORK.HELLO.
WHERE PUT(phone, TEST10.)=' Y';
Now the TEST. format is being referred to as "TEST10."--SAS apparently
likes
to append the label length to the format name?
There are probably thousands of you out there nodding your heads and
saying
"Well, duh, of course!", but I've never run across this particular bit
of
fun before.