turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- DIsplaying only sum of a column

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-21-2016 04:49 PM

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 ..

thanx in advance

Junaid F.

Accepted Solutions

Solution

08-21-2016
07:40 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-21-2016 06:43 PM

Proc means

proc means data=have sum;

var Salary;

run;

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

All Replies

Solution

08-21-2016
07:40 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-21-2016 06:43 PM

Proc means

proc means data=have sum;

var Salary;

run;

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-21-2016 07:36 PM - edited 08-21-2016 07:40 PM

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.

What I got was this:

**The MEANS Procedure**

**Analysis Variable : Salary**

Sum |

5141420.00 |

what I was trying to get was this:

~~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)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-21-2016 09:49 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-22-2016 05:35 AM

title; proc sql; select sum(weight) as Total label='Total Salary' format=dollar32.2 from sashelp.class; quit;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-22-2016 02:33 PM - edited 08-22-2016 02:35 PM

Thanks Xia Keshan

that did the trick !!!!

you da man !

Junaid F.