[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: Formats = Brain Damage
From:       Joe Matise <snoopy369 () GMAIL ! COM>
Date:       2012-11-26 21:31:33
Message-ID: CAM+YpE_bRoSqjczQMqkvJvXnU=bPEOPzQk5_bLE=YGXX3Ao4Og () mail ! gmail ! com
[Download RAW message or body]

In trying to answer this (and failing, as picture isn't going to do nearly
what the OP wants) I thought about seeing how SAS does the Z format (Zw.d).
 I thought I might CNTLOUT it to see... but it doesn't seem like you can
CNTLOUT default formats.  Anybody know if that's true, or if there is a
library somewhere that stores the default formats/informats that you can
use CNTLOUT with to see how they operate?  Or are they hardcoded in SAS?

-Joe


On Mon, Nov 26, 2012 at 3:27 PM, Mike Rhoads <RHOADSM1@westat.com> wrote:

> Jeff,
>
> If you're using SAS 9.3, you could get pretty close to what you want by
> taking advantage of its ability to have formats "call" functions, including
> functions you write yourself in PROC FCMP.  See Rick Langston's paper
> "Using the New Features in PROC FORMAT" for a good discussion.
> http://support.sas.com/resources/papers/proceedings12/245-2012.pdf
>
> The syntax is as follows:
>
> proc format;
>   value myfmt  other=[myfunc()];
> run;
>
> When the format is used, the function MYFUNC gets the value to be
> formatted, and can take advantage of nearly anything the DATA step can do
> in order to get the output the way you want it.
>
> There is a bit of a hangup with your requirement for writing 0 with a
> varying number of decimal places, since the function doesn't have access to
> the number of decimal places in the format specification.  You could work
> around this by creating a family of 5 formats (myfmt2d - myfmt6d) and 5
> parallel "placeholder" functions (myfunc2d - myfunc6d), along with your
> "real" function (myfunc).  Each format would be paired with its
> corresponding placeholder function, and the placeholder function would then
> call the actual function, passing it both the value to be formatted and the
> number of decimal places desired.
>
> (If you're not running 9.3 yet, good luck!)
>
>
> Mike Rhoads
> RhoadsM1@Westat.com
>
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jeff
> Kroll
> Sent: Monday, November 26, 2012 1:23 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Formats = Brain Damage
>
> OK, Ive been trying to design a format thaw will do the following but Im
> just not getting it.
>
> 1. The value must always be output as 17 characters, zero filled.
> 2. The value must begin with a - or + depending on the sign of the value
> and the -/+ must always be in the first column.
> 3. I need to be able to specify from 2 to 6 positions to the right of the
> decimal.
>
> ex:
>
> 1.23  should be     +000000000001.23
> 0.123456 should be  +00000000.123456
> -123.4567 should be -0000000123.4567
> 0 should be         +000000000000.00 or +0000000000.0000 or
> +00000000.000000 depending on how I tell it to write the value.
>
> Is this possible with a single format?
>
> Jeff
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic