|
Kinda like preprocessing the data:
proc sql;
select compress('_c' || put(monotonic() + 1,2.) || '_') as col
into :coltotal separated by ','
from ( select distinct year from a )
;
%put &coltotal;
quit;
proc report data=a missing nowd;
column team year total;
define team / group ;
define year / across ;
define total / computed "Total" ;
compute total;
total=sum(&coltotal);
endcomp;
run;
-----Original Message-----
From: Quentin McMullen [mailto:quentin_mcmullen@BROWN.EDU]
Sent: January 23, 2004 5:29 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: proc report summing an across variable
Hi All,
My reading of the docs is that the only way to total an "across" variable
is by referring to the columns as _c2_ _c3_ etc. Is that right?
That's a bummer. In example below, it means that every year that I add
data, I would need to modify the report code to make sure the new year's
data is included in the total.
Is there a better way to do this? Or is there a way to dynamically get
the number of columns (I guess I could always pre-process the data....)
data a;
input year team $20.;
cards;
2004 New England
2003 Tampa Bay
2002 New England
2001 Baltimore
2000 St.Louis
;
run;
options missing='0';
title "21st Century Superbowl Wins";
proc report data=a missing nowd;
column team year total;
define team / group ;
define year / across ;
define total / computed "Total" ;
compute total;
total=sum(_c2_, _c3_, _c4_, _c5_, _c6_);
endcomp;
run;
Kind Regards,
--Quentin
|