BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jim_Ogilvie
Obsidian | Level 7

Hi all,

 

I'm am putting together a proc report for output to ODS Excel, which contains several computed fields, for example, "Price per Tonne", which as you can probably guess, is "Revenue" divided by "Tonnes".

 

I want to replicate this in a summary row on my report, but using this:

 

* Grand totals;

rbreak after / summarize style(summary)={font_weight=bold  backgroundcolor=gwh  color=firebrick};
   

Gives a total of the "Price per Tonne" column, and not the computation of Total Revenue / Total Tonnes.

 

Is there an option to continue use of the computed field into the summary/grand total row?

 

Thanks

 

Jim

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
infile cards expandtabs ;
input Region & $20. Revenue	Tonnes;
cards;
Region A	 2033.9	171024.7	
Region B	 7236.7	626710.71	
;
proc report data=have nowd;
column Region   Revenue	Tonnes want;
define Region/display;
define  Revenue/analysis sum;
define Tonnes/analysis sum;
define want/computed;
compute want;
 want=Tonnes.sum/ Revenue.sum;
endcomp;
compute after;
 Region='Total';
endcomp;
rbreak after/summarize;
run;

View solution in original post

3 REPLIES 3
Ksharp
Super User
Can you give an example ?
Try

proc report data=sashelp.class nowd;
column name weight;
define name/display;
define weight/analysis sum;
compute after;
name='xxxx';
endcomp;
rbreak after/summarize;
run;
Jim_Ogilvie
Obsidian | Level 7

Sure Kevin:

 

Region Revenue Tonnes Have Want
Region A 2033.9 171024.7 84.1 84.1
Region B 7236.7 626710.71 86.6 86.6
Total 9270.6 797735.41 170.7 86.1

 

In the above example, the 84,1 and 86.6 values are being computed. The "Have" column, shows my current output, the "Want" shows the desired output, which in Excel terms would be a copy-paste of the formula in the cell above.

 

Ksharp
Super User
data have;
infile cards expandtabs ;
input Region & $20. Revenue	Tonnes;
cards;
Region A	 2033.9	171024.7	
Region B	 7236.7	626710.71	
;
proc report data=have nowd;
column Region   Revenue	Tonnes want;
define Region/display;
define  Revenue/analysis sum;
define Tonnes/analysis sum;
define want/computed;
compute want;
 want=Tonnes.sum/ Revenue.sum;
endcomp;
compute after;
 Region='Total';
endcomp;
rbreak after/summarize;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1064 views
  • 0 likes
  • 2 in conversation