BookmarkSubscribeRSS Feed
vinod4842
Fluorite | Level 6

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;

 

 

 

c.PNG

 

5 REPLIES 5
jdwaterman91
Obsidian | Level 7

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;

 

vinod4842
Fluorite | Level 6
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
kiranv_
Rhodochrosite | Level 12

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

 

Reeza
Super User

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

 

 

kiranv_
Rhodochrosite | Level 12

Yes, You are right @Reeza

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 894 views
  • 1 like
  • 4 in conversation