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

Write a code that produces the SUM of Salary corresponding to Male and Female . Create a data in name of SUM_Report. 

 

give me some hints for this question

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

A small example to get you started on the syntax

 

proc means data=sashelp.baseball sum;
   class team;
   var salary;
   output out=Salary_Sums sum=sum;
run;

Though, the best starting point is the PROC MEANS Documentation.

View solution in original post

6 REPLIES 6
Astounding
PROC Star

To start, you will need to read the documentation on PROC MEANS:

 

http://documentation.sas.com/?docsetId=proc&docsetTarget=p0f0fjpjeuco4gn1ri963f683mi4.htm&docsetVers...

 

Here are some of the items you will need to focus on.

 

You need to know the names of the variables in your data set, as well as the name of the data set itself.  All of those need to be inserted into your program in the proper place.

 

The easiest way to get what you need is to sort your data set, and use a BY statement after that within PROC MEANS.  To get separate statistics for Male and Female, the variable that takes on values of "Male" or "Female" will be your BY variable.

 

The name of your data set goes on the PROC statement.

 

The name of your output data set goes on the OUTPUT statement.  You'll need to refer to the documentation for some of the details, like how do you specify what variable name should be used to hold the sum.

 

If you try it, you'll almost certainly make progress.  If you get stuck, post what you did and where you got stuck.

Abhau
Calcite | Level 5
Thank you .
but in proc means it doesn't take an alphabetical variable . the name of variable (Gender) in gender all the observations are male female but it is written like( M F)
it is not showing result
Abhau
Calcite | Level 5
first i've to sort my data set
PeterClemmensen
Tourmaline | Level 20

A small example to get you started on the syntax

 

proc means data=sashelp.baseball sum;
   class team;
   var salary;
   output out=Salary_Sums sum=sum;
run;

Though, the best starting point is the PROC MEANS Documentation.

Abhau
Calcite | Level 5
thank you .
but in proc means it doesn't take an alphabetical variable . the name of variable (Gender) in gender all the observations are male female but it is written like( M F)
it is not showing result
ballardw
Super User

@Abhau wrote:
thank you .
but in proc means it doesn't take an alphabetical variable . the name of variable (Gender) in gender all the observations are male female but it is written like( M F)
it is not showing result

Show the code and any messages from the log. Copy from the log and paste into a code box opened using the forum's {I} icon.

 

The CLASS statement in Proc Means will take "alphabetical" variables. The BY statement will take "alphabetical" variables. The VAR, FREQ and WEIGHT statements will not take "alphabetical" variables.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1595 views
  • 1 like
  • 4 in conversation