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 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 17:49:30 -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

And yet another possibility, in addition to the several excellent suggestions already posted, is to specify a sufficiently long default length when creating the format:

proc format library=work; value test (default=10) 9165551212='Y'; run;

Mike Rhoads Westat RhoadsM1@Westat.com

-----Original Message----- From: Jeff Voeller [mailto:c-jeff.voeller@MCI.COM] Sent: Monday, January 05, 2004 4:54 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Odd format behavior and workaround

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