LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (January 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 5 Jan 2004 14:54:33 -0800
Reply-To:     Jeff Voeller <c-jeff.voeller@MCI.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jeff Voeller <c-jeff.voeller@MCI.COM>
Subject:      Re: Odd format behavior and workaround
Comments: cc: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
In-Reply-To:  <sff98245.006@SLCM02.firsthealth.com>
Content-type: text/plain; charset=us-ascii

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

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jack Hamilton Sent: Monday, January 05, 2004 2:26 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Odd format behavior and workaround

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.


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