DATA Step, Macro, Functions and more

proc means

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

proc means

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


Accepted Solutions
Solution
3 weeks ago
PROC Star
Posts: 1,400

Re: proc means

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


All Replies
Super User
Posts: 6,934

Re: proc means

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.

Occasional Contributor
Posts: 9

Re: proc means

Posted in reply to Astounding
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
Occasional Contributor
Posts: 9

Re: proc means

Posted in reply to Astounding
first i've to sort my data set
Solution
3 weeks ago
PROC Star
Posts: 1,400

Re: proc means

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.

Occasional Contributor
Posts: 9

Re: proc means

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
Super User
Posts: 13,941

Re: proc means


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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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