Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Output PROC MEANS to a file/SAS data table

Writer Matthew Martinez

In PROC FREQ procedure we can specify an output table in the following terms:

 Proc Freq DATA=LIB.TABLE_IN ORDER=FREQ; TABLES FIELD / MISSING OUT = LIB.TABLE_OUT; /* outputs to a SAS data table */ RUN;

How could we do the same with PROC MEANS procedure?

proc means data=LIB.TABLE_IN n nmiss;

Thanks for helping!

1

3 Answers

Two ways. The output statement sends output to a dataset; you also can use ods output as you can with any proc.

proc means data=sashelp.class; class sex; types sex; var height weight; output out=class_means mean= sum= /autoname;
run;

To use ods output you need to know the name of the table produced by the proc. You can use ODS TRACE to find out what the name of the table is.

ods trace on;
proc means data=sashelp.class; class sex; types sex; var height weight;
run;
ods trace off;

You'll find it's called summary. So you add ods output statement like so:

ods output summary=class_means_ods;
proc means data=sashelp.class; class sex; types sex; var height weight; output out=class_means mean= sum= /autoname;
run;
ods output close;

Finally, proc means has an option after I think 9.3 (or maybe 9.22) stackodsoutput which changes the format of the resulting dataset to be more tabular, which may be helpful for you.

ods output summary=class_means_ods;
proc means data=sashelp.class stackodsoutput; class sex; types sex; var height weight; output out=class_means mean= sum= /autoname;
run;
ods output close;
0

Nearly anything you can do with proc means that produces output in the listing area can also be produced via proc summary as an output dataset, albeit sometimes with slightly different syntax and in a different output format. E.g. this produces the same information as your example, but in a wide table rather than a long one:

proc summary data=sashelp.class; var _numeric_; output out = my_summary n= nmiss= /autoname;
run;
4

If you need only N, MIN,MAX, MEAN, and STD, the simple lines below can produce a nice table, here named 'sumTab'. however, if you add NMISS and others, it will be in a wide format.

 proc means data = X ; var _numeric_; output out = sumTab ; run;

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.