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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

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

View solution in original post

6 REPLIES 6
Cynthia_sas
SAS Super FREQ

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

George_S
Fluorite | Level 6


Thank you Cynthia,

I looked into the means document:please 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!

Linlin
Lapis Lazuli | Level 10

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;

George_S
Fluorite | Level 6

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;

Linlin
Lapis Lazuli | Level 10

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

Ksharp
Super User

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

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 993 views
  • 3 likes
  • 4 in conversation