Solved
Contributor
Posts: 35

# Is there any difference for the proc mean here?

1.

proc means sum data = one nway noprint;

class x y;

var a;

output out = two;

run;

2.

proc means mean data = one nway noprint;

class x y;

var a;

output out = two;

run;

3.

proc means data = one nway noprint;

class x y;

var a

output out = two;

run;

I can't see any different among 1,2 and 3,they are same. but why?

Thanks

Accepted Solutions
Solution
‎04-10-2012 04:25 PM
Super Contributor
Posts: 1,636

## Re: Is there any difference for the proc mean here?

yes, I noticed the red color parts.

The color parts have effect only on the print out. You couldn’t see the effect because you used noprint.

proc means  sum data = sashelp.class nway ;

class sex;

var age;

output out = two ;

run;

The MEANS Procedure

Analysis Variable : Age

N

Sex    Obs             Sum

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

F        9     119.0000000

M       10     134.0000000

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

/*2.*/

proc means mean data = sashelp.class nway ;

class sex;

var age;

output out = two2;

The MEANS Procedure

Analysis Variable : Age

N

Sex    Obs            Mean

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

F        9      13.2222222

M       10      13.4000000

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

run;

If you want to see the effect on the output datasets, you need to add sum, mean to the output statement.

proc means  data = sashelp.class nway noprint;

class sex;

var age;

output out = two1 sum= ;

run;

/*2.*/

proc means  data = sashelp.class nway noprint;

class sex;

var age;

output out = two2 mean=;

run;

Message was edited by: Linlin

All Replies
SAS Super FREQ
Posts: 9,371

## Re: Is there any difference for the proc mean here?

Hi:

You control what gets written to the output data set (OUTPUT OUT= file) by listing the statistics & variables on the OUTPUT statement. Without any other instructions from you, you will always get the same 5 statistics: N, MEAN, MIN, MAX, STD.

Look in the PROC MEANS documentation for examples of specifying the statistics you want, with the names you want on the OUTPUT statement.

cynthia

Contributor
Posts: 35

## Re: Is there any difference for the proc mean here?

Thank you Cynthia,

I looked into the means documentlease see the red color  blow, in my question the statistics-keywords 'sum' and 'mean' don't have any effect,why?

PROC MEANS <option(s)> <statistic-keyword(s)>; BY <DESCENDING> variable-1 <... <DESCENDING> variable-n><NOTSORTED>;

CLASS variable(s) </ option(s)>;

FREQ variable;

ID variable(s);

OUTPUT <OUT=SAS-data-set> <output-statistic-specification(s)>

<id-group-specification(s)> <maximum-id-specification(s)>

<minimum-id-specification(s)> </ option(s)> ;

TYPES request(s);

VAR variable(s) < / WEIGHT=weight-variable>;

WAYS list;

WEIGHT variable;

The example is:

/*1*/

proc means  sum data = sashelp.class nway noprint;
class sex;
var age;
output out = two1;
run;

/*2.*/

proc means  mean data = sashelp.class nway noprint;
class sex;
var age;
output out = two2;
run;

why two1 and two2 are same?

Thanks!

Super Contributor
Posts: 1,636

## Re: Is there any difference for the proc mean here?

If you want to see the difference, you need to put the statistics in output statement.

/* 1 */

proc means  data = sashelp.class nway noprint;

class sex;

var age;

output out = two1 sum= ;

run;

/*2.*/

proc means  data = sashelp.class nway noprint;

class sex;

var age;

output out = two2 mean=;

run;

/*3*/

proc means  data = sashelp.class nway noprint;

class sex;

var age;

output out = two3;

run;

and you will see the difference if you take out the noprint in your code.

proc means sum data = one nway /*noprint*/;

class x y;

var a;

output out = two;

run;

2.

proc means mean data = one nway /*noprint*/;

class x y;

var a;

output out = two;

run;

3.

proc means data = one nway /*noprint*/;

class x y;

var a

output out = two;

run;

Contributor
Posts: 35

## Re: Is there any difference for the proc mean here?

Thank you LinLin, please notice the red part.

I didn't see any difference for 1,2 and 3.

Do the red color parts have no any effect?

I revised your example as follow,the three results are identical,why?  It seems the sum and mean in the proc statement don't have any effect.

/*1*/

proc means  sum data = sashelp.class nway noprint;
class sex;
var age;
output out = two1;
run;

/*2.*/

proc means  mean data = sashelp.class nway noprint;
class sex;
var age;
output out = two2;
run;

/*3*/

proc means  data = sashelp.class nway noprint;
class sex;
var age;
output out = two3;
run;

Solution
‎04-10-2012 04:25 PM
Super Contributor
Posts: 1,636

## Re: Is there any difference for the proc mean here?

yes, I noticed the red color parts.

The color parts have effect only on the print out. You couldn’t see the effect because you used noprint.

proc means  sum data = sashelp.class nway ;

class sex;

var age;

output out = two ;

run;

The MEANS Procedure

Analysis Variable : Age

N

Sex    Obs             Sum

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

F        9     119.0000000

M       10     134.0000000

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

/*2.*/

proc means mean data = sashelp.class nway ;

class sex;

var age;

output out = two2;

The MEANS Procedure

Analysis Variable : Age

N

Sex    Obs            Mean

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

F        9      13.2222222

M       10      13.4000000

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

run;

If you want to see the effect on the output datasets, you need to add sum, mean to the output statement.

proc means  data = sashelp.class nway noprint;

class sex;

var age;

output out = two1 sum= ;

run;

/*2.*/

proc means  data = sashelp.class nway noprint;

class sex;

var age;

output out = two2 mean=;

run;

Message was edited by: Linlin

Super User
Posts: 10,784

## Re: Is there any difference for the proc mean here?

The red part only is used to display at output window which will not write into output dataset.

So your output dataset will always be the same.

Ksharp

🔒 This topic is solved and locked.