Date: Fri, 26 May 2006 13:21:00 -0400
Reply-To: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject: Re: PROC SQL Sum Into Macro Variable
Content-Type: text/plain; charset="us-ascii"
Talbot:
I haven't tested this form of query, but believe that it should work as
advertised:
proc sql ;
reset noprint ;
select sum(x * (x ge &lim.)) format=12.2
into :sum_x_above_lim
from ds1
;
quit ;
The conversion to character type, of course, makes number representation
problematic. Easy to test, though.
Sig
-----Original Message-----
From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
On Behalf Of Talbot Michael Katz
Sent: Friday, May 26, 2006 12:12 PM
To: SAS-L@LISTSERV.UGA.EDU
Cc: Talbot Michael Katz
Subject: PROC SQL Sum Into Macro Variable
Hi.
Please have patience with me. I think I asked a question like this
before, but somehow I still haven't gotten it.
When I sum into macro variable as follows:
proc sql ;
reset noprint ;
select sum(x * (x ge &lim.))
into :sum_x_above_lim
from ds1
;
quit ;
310 %put sum_x_above_lim =
310! %sysfunc(putn(&sum_x_above_lim.,comma15.2)) ;
sum_x_above_lim = 16,610,879.00
316 %put sum_x_above_lim = &sum_x_above_lim. ;
sum_x_above_lim = 16610879
When I sum the same into a data set:
proc sql ;
create table sum_x_above_lim as
select sum(x * (x ge &lim.)) as
sum_x_above_lim
from ds1
;
quit ;
and I print out the value I get: 16610879.18
Why am I losing the part after the decimal point in the macro variable?
-- TMK --
"The Macro Klutz"