BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASdevAnneMarie
Rhodochrosite | Level 12

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 !

1 ACCEPTED SOLUTION

Accepted Solutions
Kathryn_SAS
SAS Employee

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/ 

View solution in original post

8 REPLIES 8
yabwon
Amethyst | Level 16

Use Maxim 1.

 

N, MIN, MAX, MEAN, STD are default.

Red doc: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p04vbvpcjg2vrjn1v8wyf0daypfi.htm#n031c5t...

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

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SASdevAnneMarie
Rhodochrosite | Level 12

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. 

Kathryn_SAS
SAS Employee

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
Rhodochrosite | Level 12
Thank you, Kathryn!
yabwon
Amethyst | Level 16

@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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



ballardw
Super User

@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.

FreelanceReinh
Jade | Level 19

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.

Ksharp
Super User

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;

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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
  • 8 replies
  • 556 views
  • 4 likes
  • 6 in conversation