Hello Experts,
I'm wondering why in proc means output out I have only a few default stats : N
MIN
MAX
MEAN
STD ?
Thank you !
If you want statistics other than the default in the output data set, you need to explicitly name them as follows:
proc means data=bdd vardef=N mean std var cv median max min q1 q3 maxdec=5;
output out=sumstat mean= std= var= cv=median= max= min= q1= q3= / autoname;
run;
proc print data=sumstat;
run;
To reshape the output data set, consider the following:
http://support.sas.com/kb/42/381.html
https://blogs.sas.com/content/sgf/2015/07/17/customizing-output-from-proc-means/
Use Maxim 1.
N, MIN, MAX, MEAN, STD are default.
to how to change them.
Check the examples too, e.g., https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n01kt03q5ggzgkn18we7i8i9ixie.htm#n01kt03...
Bart
Thank you,
My code is:
proc means data=bdd vardef=N mean std var cv median max min q1 q3 maxdec=5;
output out=sumstat;
run;
I do not have cv, q1 ,q3 and median in table sumstat.
If you want statistics other than the default in the output data set, you need to explicitly name them as follows:
proc means data=bdd vardef=N mean std var cv median max min q1 q3 maxdec=5;
output out=sumstat mean= std= var= cv=median= max= min= q1= q3= / autoname;
run;
proc print data=sumstat;
run;
To reshape the output data set, consider the following:
http://support.sas.com/kb/42/381.html
https://blogs.sas.com/content/sgf/2015/07/17/customizing-output-from-proc-means/
@SASdevAnneMarie don't cheat 😉
You didn't read to the doc. in the link I've shared... If you did, you would knew that you should provide statistical keywords in the OUTPUT statement of MEANS Procedure.
Look at the snippet shared by @Kathryn_SAS, it will guide you.
All the best
Bart
@SASdevAnneMarie wrote:
Thank you,
My code is:
proc means data=bdd vardef=N mean std var cv median max min q1 q3 maxdec=5; output out=sumstat; run;I do not have cv, q1 ,q3 and median in table
sumstat.
Once upon a time in SAS there were two procedures Means and Summary. Means sent results to the default output device such as screen or printer. Proc summary sent output to data sets. And the two were separate. At some point the procedures were merged in proc means somewhat. So the default statistics on the procedure statement remain as the statistics sent to the default output screen but those do not affect the default behavior of the output statement which was brought in from proc summary.
And don't forget that there are options now that will make output data sets with the ODS OUTPUT statement that will appear in a different form than the Output statement and can have a different structure using the STACKODSOUTPUT option.
Hello @SASdevAnneMarie,
If you need (a lot) more statistics by default, use PROC UNIVARIATE.
For an individual selection of statistics that you need regularly, you could define one or more lists of statistics keywords in macro variables and use them with PROC MEANS.
Example:
%let mystats=n mean cv clm qrange min q1 median q3 max;
proc means data=sashelp.class &mystats;
var height;
run;
You may want to add the %LET statement to your autoexec file, so that the definition of MYSTATS is automatically available in every SAS session.
1) You could use the following code to get the statistical estimators as you need.
proc summary data=sashelp.class nway; class sex; var weight; output out=want min= max= cv= median=/autoname; run;
2)You could use PROC UNIVARIATE to get all these stats once for all.
proc univariate data=sashelp.class outtable=want2 noprint; class sex; var weight; run;
Dive into keynotes, announcements and breakthroughs on demand.
Explore Now →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.
Ready to level-up your skills? Choose your own adventure.