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

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!

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.

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
  • 11524 views
  • 1 like
  • 5 in conversation