Desktop productivity for business analysts and programmers

PROC SQL: Sum

Reply
Occasional Contributor
Posts: 5

PROC SQL: Sum

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!

Respected Advisor
Posts: 3,251

Re: PROC SQL: Sum

Posted in reply to NabihaGhadie

It's pretty simple in PROC REPORT.

--
Paige Miller
Occasional Contributor
Posts: 5

Re: PROC SQL: Sum

Posted in reply to PaigeMiller

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

Respected Advisor
Posts: 3,251

Re: PROC SQL: Sum

Posted in reply to NabihaGhadie

@NabihaGhadie 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
Ask a Question
Discussion stats
  • 3 replies
  • 84 views
  • 1 like
  • 2 in conversation