BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jfaruqui
Obsidian | Level 7

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

View solution in original post

5 REPLIES 5
Reeza
Super User

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

jfaruqui
Obsidian | Level 7

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) 

 

Reeza
Super User

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. 

Ksharp
Super User

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

Thanks Xia Keshan

 

 

that did the trick !!!!

you da man !

 

Junaid F.

 

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 12716 views
  • 0 likes
  • 3 in conversation