Date: Tue, 28 Jul 2009 09:04:09 -0500
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: Picture format issue
In-Reply-To: <200907281357.n6SAlPmd029979@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
The doc is certainly confusing, but it means 'you must use zero digit
selectors *to keep space for the prefix*'. IE, if your prefix is 1 long,
then you must have one 0 at the start of your format to hold the place for
your prefix. The picture will only be as long as you define space for with
0's.
Example:
proc format lib=work;
picture pay low-high='000,009.99'
(prefix='$');
quit;
data test;
x=250000;
output;
x=25000;
output;
format x pay.;
run;
proc print; run;
First line has no $, second does; because the first only has room for the
numeric in the 6 pre-decimal places.
Certainly a place where the doc could be a bit clearer, though.
Joe
On Tue, Jul 28, 2009 at 8:57 AM, Jonathan Goldberg
<jgoldberg@biomedsys.com>wrote:
> Joe:
>
> Thanks for the suggestion. It's better than the workaround I had, and
> I'll use it.
>
> I was deceived by this:
>
> PREFIX='prefix'
> specifies a character prefix to place in front of the value's first
> significant digit. You must use zero digit selectors or the prefix will
> not be used.
>
> from the picture statement documentation. I interpreted "zero digit
> selectors" as "only zero digit selectors," obviously wrongly.
>
> I still don't understand why I need it. The "0" in the picture string is
> a digit selector, and zero is a digit. Oh well.
>
>
> On Mon, 27 Jul 2009 17:57:00 -0500, Joe Matise <snoopy369@GMAIL.COM>
> wrote:
>
> >The problem is that '0000000' gives no output (blank) with 0. Try this:
> >proc format lib=work;
> > picture firsttry
> > -1 = 'Pre-dose'
> > 0 - high = '000000009'
> > (prefix = 'Hour ');
> >quit;
> >
> >data test;
> >do _n_ = 0 to 4;
> > format _n_ firsttry.;
> > put _n_=;
> >end;
> >run;
> >
> >-Joe
> >
> >On Mon, Jul 27, 2009 at 5:42 PM, Jonathan Goldberg
> ><jgoldberg@biomedsys.com>wrote:
> >
> >> Why doesn't the code in picture firsttry correctly format a
> >> 0? I thought I'd get "Hour 0" as the output; instead, I got
> >> nothing. I can word around the problem, as picture secondtry
> >> does, but why should I need to?
> >>
> >> Jonathan
> >>
> >> 1052 proc format;
> >> 1053 picture firsttry
> >> 1054 -1 = 'Pre-dose'
> >> 1055 0 - high = '000000000'
> >> 1056 (prefix = 'Hour ')
> >> 1057 ;
> >> NOTE: Format FIRSTTRY has been output.
> >> 1058
> >> 1059 picture secondtry
> >> 1060 -1 = 'Pre-dose'
> >> 1061 0 = 'Hour 0' (noedit)
> >> 1062 1 - high = '000000000'
> >> 1063 (prefix = 'Hour ')
> >> 1064 ;
> >> NOTE: Format SECONDTRY has been output.
> >> 1065 run;
> >>
> >> NOTE: PROCEDURE FORMAT used (Total process time):
> >> real time 0.04 seconds
> >> cpu time 0.01 seconds
> >>
> >>
> >> 1066
> >> 1067 data _null_;
> >> 1068 do i = 0 to 3;
> >> 1069 put i=firsttry.;
> >> 1070 end;
> >> 1071 put '----------';
> >> 1072 do i = 0 to 3;
> >> 1073 put i=secondtry.;
> >> 1074 end;
> >> 1075 run;
> >>
> >> i=
> >> i=Hour 1
> >> i=Hour 2
> >> i=Hour 3
> >> ----------
> >> i=Hour 0
> >> i=Hour 1
> >> i=Hour 2
> >> i=Hour 3
> >> NOTE: DATA statement used (Total process time):
> >> real time 0.06 seconds
> >> cpu time 0.00 seconds
> >>
>
|