BookmarkSubscribeRSS Feed
JibJam221
Obsidian | Level 7

Hello, I am looking to add a "grand totals" row at the end of my report, that provides a sum of each column in the dataset. Is there any way to do this?

First, I created a dataset to calculate the variables (PR) and (AB) to populate the columns. 

proc sql;
create table tbl_AP as
 select
  Grlvl as GROUP,
  count(PR) as Total,
  count (AB) as Ind
from db.emp
 where GROUP= 3
 group by Grlvl;
quit;

Then, I make this into a report, and add an extra column to calculate the percentage of a specific population using the two variables from tbl_AP.

 

proc sql;
Title "Distribution of People in";
select GROUP label="G-L",
 Total,
 Ind,
 Ind/Total as Ins_Percentage format=Percent8.1 label= " %"
from tbl_AP;
quit;

 

Thanks!

3 REPLIES 3
PaigeMiller
Diamond | Level 26

It's pretty simple in PROC REPORT.

--
Paige Miller
JibJam221
Obsidian | Level 7

awesome! Would I use PROC Report after putting the table together, or would this only need one PROC statement altogether?

PaigeMiller
Diamond | Level 26

@JibJam221 wrote:

awesome! Would I use PROC Report after putting the table together, or would this only need one PROC statement altogether?


Either. It's up to you.

 

There are examples in the PROC REPORT documentation of using the RBREAK command to add summary statistics at the bottom of the report.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1504 views
  • 1 like
  • 2 in conversation