## DIsplaying only sum of a column

Solved
Occasional Contributor
Posts: 9

# DIsplaying only sum of a column

I guess this a very silly question .. I have just started base SAS programming and will probably be able to figure this out eventually.

I have a data set with 165 observation for which one of the variables is salary.

I am writing a data step to display certain variables in the 2 outputs.:

one is employee data (which i am able to do) which would be a table looking like this:

" | Emp. ID | Employee Name | Gender | Country | "

Additionally (the problem part) I wish to display the SUM of the total salaries paid to all the employees without showing each and every salary figure.

Basically another table (like a little footnote) below the aforementioned table which would just be something like:

| obs | total salary disbursed   |

-----------------------------------

|  01  |     (sum of all salaries)   |

-----------------------------------

Just a "one observation" table below my employee data table ... (I'm pretending that my boss only wants to know the total amount in salaries he has to pay each month and doesn't care to look at the individual amounts) ...

This is probably super easy but I am stuck and would appreciate some help on this ..

Junaid F.

Accepted Solutions
Solution
‎08-21-2016 07:40 PM
Super User
Posts: 23,677

## Re: DIsplaying only sum of a column

Proc means

proc means data=have sum;

var Salary;

run;

If your using Proc print you can also look at the SUM statement.

http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n04nvolcvwcb78n1gk4we...

All Replies
Solution
‎08-21-2016 07:40 PM
Super User
Posts: 23,677

## Re: DIsplaying only sum of a column

Proc means

proc means data=have sum;

var Salary;

run;

If your using Proc print you can also look at the SUM statement.

http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n04nvolcvwcb78n1gk4we...

Occasional Contributor
Posts: 9

## Re: DIsplaying only sum of a column

[ Edited ]

Thanx Reeza

The proc means does the trick  .. but I don't think I can do anything about formatting the output other than to accept the SAS default.

The MEANS Procedure

Analysis Variable : Salary

 Sum 5141420.00

The MEANS Procedure

Analysis Variable : Salary

 Total Salary Disbursed \$5,141,420.00

The "SUM Salary;" statement in proc print lists out the entire "Salary" column with a total at the bottom even though I leave it out of the VAR statement and it doesnt give me the answer as a separate table under my main data table in the output.

Nevertheless Sir, thanks a lot, this really helped ... I'll try to figure out the custom formatting somehow if possible.

Regards

Junaid F.

(extreme novice)

Super User
Posts: 23,677

## Re: DIsplaying only sum of a column

Simplest way is to create data in a dataset and print it.

Use either proc means or Proc SQL to create table.

Proc tabulate can do it on one step.

ODS noptitle;

Proc tabulate data=have;

var salary;

table salary*sum='Total Salary';

run;

Look at Ptitle option for suppressing the Proc title.

Super User
Posts: 10,766

## Re: DIsplaying only sum of a column

```
title;
proc sql;
select sum(weight) as Total label='Total Salary' format=dollar32.2
from sashelp.class;
quit;
```
Occasional Contributor
Posts: 9

## Re: DIsplaying only sum of a column

[ Edited ]

Thanks Xia Keshan

that did the trick !!!!

you da man !

Junaid F.

☑ This topic is solved.