BookmarkSubscribeRSS Feed
alokranjan1502_gmail_com
Calcite | Level 5

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)

6 REPLIES 6
Fugue
Quartz | Level 8

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.

alokranjan1502_gmail_com
Calcite | Level 5

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

AncaTilea
Pyrite | Level 9

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.

data_null__
Jade | Level 19

What about AUTONAME ouput statement option.

Reeza
Super User

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

46427 - STACKODSOUTPUT new for PROC MEANS in SAS 9.3

AncaTilea
Pyrite | Level 9

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!!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 12778 views
  • 1 like
  • 5 in conversation