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

How could I use a procedure to calculate the average salary and also the number of ppl in each department. The code I have tried gives the following message: Statement is not valid or it is used out of proper order. Not sure what the problem is. I was trying to use proc means to do this.

 

Dataset is attached.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

HINT: When you get an error copy the code from the log along with the message and paste that into a code box opened with the forum's {I} icon.

 

Do you want a data set (for further manipulation) or a report (people read these)?

 

Better is to post a data step representative of your data. Not all versions of SAS can use your data sets natively and it is extra work for use to 1) download, 2) make the set available to code and then test.

 

I am assuming that "ppl" means people. Depending on how your actual data is structured that may be very easy or somewhat tricky.

 

I would likely start with something like:

proc means data=combo n mean;

   class dept;

   var salary;

run;

 

if none of your people appear more than once. If the same person is in more than one department for some reason you'll have to decide how to handle that.

View solution in original post

2 REPLIES 2
ballardw
Super User

HINT: When you get an error copy the code from the log along with the message and paste that into a code box opened with the forum's {I} icon.

 

Do you want a data set (for further manipulation) or a report (people read these)?

 

Better is to post a data step representative of your data. Not all versions of SAS can use your data sets natively and it is extra work for use to 1) download, 2) make the set available to code and then test.

 

I am assuming that "ppl" means people. Depending on how your actual data is structured that may be very easy or somewhat tricky.

 

I would likely start with something like:

proc means data=combo n mean;

   class dept;

   var salary;

run;

 

if none of your people appear more than once. If the same person is in more than one department for some reason you'll have to decide how to handle that.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 636 views
  • 0 likes
  • 3 in conversation