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.
Proc means
proc means data=have sum;
var Salary;
run;
If your using Proc print you can also look at the SUM statement.
Proc means
proc means data=have sum;
var Salary;
run;
If your using Proc print you can also look at the SUM statement.
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)
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.
title; proc sql; select sum(weight) as Total label='Total Salary' format=dollar32.2 from sashelp.class; quit;
Thanks Xia Keshan
that did the trick !!!!
you da man !
Junaid F.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.