Contributor
Posts: 23

# How to calculate totals

[ Edited ]

I am looking for salary total. What can I do for that? Please rectify my query.

`proc import datafile="C:\Users\user\Desktop\result of sas\Assignments\EMPLOYEE.csv" out=work.employee dbms=csv replace; run; data emp; FORMAT salary dollar8.; set work.employee; run; `

Contributor
Posts: 23

## Re: How to calculate totals

Posted in reply to vinod4842

There are multiple ways of acquiring the sum of a column in SAS.

Here are a couple of ways that could work for you.

``````data Sums;
Set Employee end = last;
Retain Total;
Total + Salary;
keep Total;
if last;
Run;

Proc SQL;
Select Sum(salary) As Total_Sum
From employee;
Quit;``````

Contributor
Posts: 23

## Re: How to calculate totals

Posted in reply to jdwaterman91
57 Proc SQL;
58 Select Sum(salary) As Total_Sum
59 From employee;
ERROR: The SUM summary function requires a numeric argument.
60 Quit;

i applied this one but it is not accepted ad showing error
PROC Star
Posts: 514

## Re: How to calculate totals

Posted in reply to vinod4842

please use proc contents to see whether your column is numeric value or not and also see whether you are using column label instead  of column name(I think this is what might be happening).

Super User
Posts: 23,773

## Re: How to calculate totals

[ Edited ]

kiranv_ wrote:

please use proc contents to see whether your column is numeric value or not and also see whether you are using column label instead  of column name(I think this is what might be happening).

@kiranv_ I think Salary is a character column. You can see that becauses it's aligned right. Numeric columns are aligned left and characters are aligned right, by default.

PROC Star
Posts: 514

## Re: How to calculate totals

Yes, You are right @Reeza

Discussion stats
• 5 replies
• 159 views
• 1 like
• 4 in conversation