- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I have been trying to sort my means after computing them with the PROC MEANS function. I used the same code for the a slightly different problem. When I use the proc sort function, it tell me my variable does does exist. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Run a PROC CONTENTS to see what variables are actually in the data set you want to sort.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am curious why you decided to use the ODS OUTPUT statement instead of the more traditional OUTPUT statement.
Look at the program below and make sure you understand the differences and similarities in the print output and data sets.
/**********/
title 'proc means ods_output_stackodsoutput';
ods output summary=ods_output_stackodsoutput;
proc means data=sashelp.class mean sum std stackodsoutput;
var age height;
run;
title 'means output ods_output_stackodsoutput';
proc print data=ods_output_stackodsoutput; run;
/**********/
title 'proc means ods_output_nostackodsoutput';
ods output summary=ods_output_nostackodsoutput;
proc means data=sashelp.class mean sum std ;
var age height;
run;
title 'means output ods_output_nostackodsoutput';
proc print data=ods_output_nostackodsoutput; run;
/**********/
title 'proc means means_output_stackodsoutput';
proc means data=sashelp.class mean sum std stackodsoutput;
var age height;
output out=means_output_stackodsoutput;
run;
title 'means output means_output_stackodsoutput';
proc print data=means_output_stackodsoutput; run;
/**********/
title 'proc means means_output_nostackodsoutput';
proc means data=sashelp.class mean sum std ;
var age height;
output out=means_output_nostackodsoutput;
run;
title 'means output means_output_nostackodsoutput';
proc print data=means_output_nostackodsoutput; run;
I moved the ODS OUTPUT statements outside the PROC MEANS statements because the ODS OUTPUT statement is not part of PROC MEANS procedure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
A few comments:
I'm not a statistician, so I don't know how statisticians think, but in the business world you almost never want to run MEANS or SUMMARY (or REPORT or TABULATE) without the MISSING keyword, because you almost never want to just throw away data. You want your totals to add up to the same numbers.
It's a matter of preference, but I almost never use PROC MEANS. If I want "printed" output, I create a data set with PROC SUMMARY and then print it using PROC PRINT or TABULATE or REPORT. Those procedures are more flexible and produce better looking output. In general, REPORT and TABULATE are really useful to know, because they can produce complex output without a lot of programming on your part.
Also, none of your code contains what SAS calls a "function". PROC MEANS is a procedure, not a function. MEAN is the name of a function, and also of a statistic/keyword. Your code uses MEAN as a keyword, not as a function. Even in a PROC SUMMARY statement like OUTPUT OUT=XYZ MEAN(abc)=ABC_MEAN , the word MEAN is a keyword, even though it looks like a function.