Date: Fri, 25 Jun 2004 16:57:30 +0200
Reply-To: "Groeneveld, Jim" <jim.groeneveld@VITATRON.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Groeneveld, Jim" <jim.groeneveld@VITATRON.COM>
Subject: Re: %SYSFUNC and PUT function
Content-Type: text/plain; charset="iso-8859-1"
Hi friends,
Instead of ABS you could use MIN, MAX, MEAN, maybe SUM, maybe RESOLVE, and possibly some more functions.
Regards - Jim.
--
. . . . . . . . . . . . . . . .
Jim Groeneveld, MSc.
Biostatistician
Science Team
Vitatron B.V.
Meander 1051
6825 MJ Arnhem
Tel: +31/0 26 376 7365
Fax: +31/0 26 376 7305
Jim.Groeneveld@Vitatron.com
www.vitatron.com
Showing statistically significant differences between football teams,
generally all sporters, requires larger samples than usually applied.
[common disclaimer]
-----Original Message-----
From: Howard Schreier [mailto:Howard_Schreier@ITA.DOC.GOV]
Sent: Friday, June 25, 2004 16:46
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: %SYSFUNC and PUT function
If you know that all of your values are non-negative, then the ABS function
has no effect. But try this variation on Gordon's code:
%let mydate=25jun1959;
%let prt_d=%sysfunc(abs("&mydate"d), mmddyy10.);
%put &prt_d;
The result is
07/09/1960
because SAS dates are negative for 31 December 1959 and earlier.
I have often used techniques which are tricky and/or dependent on data
properties which I know to hold. But if there's an equally good alternative
which is more straightforward and bulletproof, I usually opt to use it. So
here I'd use PUTN.
When using PUTN *in a DATA step* with a constant as the second argument
(the format), you *would* quote it. The %SYSFUNC context is different.
On Fri, 25 Jun 2004 09:45:40 -0400, Talbot Michael Katz <topkatz@MSN.COM>
wrote:
>Hi, Gordon.
>
>I tried your trick,
>>%let v=%sysfunc(abs(&i), z4.);
>and it works fine. Elegant. Thank you.
>
>Using PUTN as others suggested also appears to work:
>%let v = %sysfunc(putn(&i.,Z4.));
>The syntax is exactly the same as what I wanted to do with PUT, but it took
>me awhile to figure that out from the PUTN documentation -- I kept wanting
>to put the format string in quotes.
>
>-- TMK --
On Thu, 24 Jun 2004 18:07:51 -0400, Buchanan, Gordon
<gordon.buchanan@GMACRFC.COM> wrote:
>You can also use the fact the the %sysfunc function lets you specify a
>format as the second parameter. This works fine:
>
>%let v=%sysfunc(abs(&i), z4.);
>
>Just use some function that does not change the value of your number; in
>this case I use ABS.
>
>I often use this to reformat date macro variables as in:
>
>%let d=25jun2004;
>%let prt_d=%sysfunc(abs("&date"d), mmddyy10.);
[snip]