LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2004, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 23 Jan 2004 18:04:59 -0500
Reply-To:   "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Subject:   Re: proc report summing an across variable
Content-Type:   text/plain; charset="iso-8859-1"

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


Back to: Top of message | Previous page | Main SAS-L page