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.

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
  • 6 replies
  • 863 views
  • 1 like
  • 4 in conversation