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)
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.
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
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.
What about AUTONAME ouput statement option.
If you're in 9.3+ another option is stackods.
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!!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.