Proc means output out statements

Reply
New Contributor
Posts: 2

Proc means output out statements

In proc means procedure, when we use output out statement to store the result of proc means into new data set, we get three new variables - _type_, _freq_, _state_. My concern is how can we set our desired statistics in _STAT_ variables. (Default is N,MEAN,MIN,MAX,STD, but i want NMISS,N,MEAN,MIN,MAX)

Super Contributor
Posts: 307

Re: Proc means output out statements

Posted in reply to alokranjan1502_gmail_com

Specify the statistics that you want in the output statement.

proc means data=yourinputdata youroptions ;

your class statement ;

your var statement ;

OUTPUT OUT=youroutputdataset NMISS= N= MEAN= MIN= MAX=;

run;

The _TYPE_ and _FREQ_ variables are automatic. Each value of _TYPE_ determines a summary level, and will depend on how many crossings you asked for (e.g NWAY). _FREQ_ is simply a count of observations.

New Contributor
Posts: 2

Re: Proc means output out statements

Thanks for your reply Fugue.

But this will not give my expected error.

You will get warning message in the log.

Here i am giving the log message that i am getting.

proc means data=college NMISS N MEAN MIN MAX ;

39   var gpa classrank;

40   class gender schoolsize;

41   output out = radhaquest7 NMISS= N= MEAN= MIN= MAX=  ;

42   run;

NOTE: Writing HTML Body file: sashtml.htm

WARNING: Variable GPA already exists on file WORK.RADHAQUEST7.

WARNING: Variable ClassRank already exists on file WORK.RADHAQUEST7.

WARNING: Variable GPA already exists on file WORK.RADHAQUEST7.

WARNING: Variable ClassRank already exists on file WORK.RADHAQUEST7.

WARNING: Variable GPA already exists on file WORK.RADHAQUEST7.

WARNING: Variable ClassRank already exists on file WORK.RADHAQUEST7.

WARNING: Variable GPA already exists on file WORK.RADHAQUEST7.

WARNING: Variable ClassRank already exists on file WORK.RADHAQUEST7.

WARNING: The duplicate variables will not be included in the output data set of the output

         statement number 1.

NOTE: There were 100 observations read from the data set WORK.COLLEGE.

NOTE: The data set WORK.RADHAQUEST7 has 12 observations and 6 variables.

NOTE: PROCEDURE MEANS used (Total process time):

      real time           2.00 seconds

      cpu time            0.31 seconds

Super Contributor
Posts: 543

Re: Proc means output out statements

Posted in reply to alokranjan1502_gmail_com

Hi, you need to name each of your variables int he output data set:

proc means data=sashelp.class NMISS N MEAN MIN MAX;

var age weight height;

OUTPUT OUT=want

NMISS=nmiss_age nmiss_height nmiss_weight

N= n_age n_height n_weight

MEAN=mean_age mean_height mean_weight

MIN=min_age min_Height min_weight

MAX= max_age max_weight max_height;

run;

Good luck.

Anca.

Respected Advisor
Posts: 3,799

Re: Proc means output out statements

Posted in reply to AncaTilea

What about AUTONAME ouput statement option.

Super User
Posts: 19,770

Re: Proc means output out statements

Posted in reply to data_null__

If you're in 9.3+ another option is stackods.

46427 - STACKODSOUTPUT new for PROC MEANS in SAS 9.3

Super Contributor
Posts: 543

Re: Proc means output out statements

Posted in reply to data_null__

Thank you!

This is great.

proc means data=sashelp.class NMISS N MEAN MIN MAX ;

var age weight height;

OUTPUT OUT=want  nmiss= n= mean= min= max= /autoname;

run;

I did not know you can do this!!

Ask a Question
Discussion stats
  • 6 replies
  • 1234 views
  • 1 like
  • 5 in conversation