![]() | ![]() | ![]() | ![]() | ![]() |
The sample code on the Full Code tab uses a simple PROC TRANSPOSE of the _STAT_ variable to produce the standard looking output that you expect to see from the MEANS procedure. The variable is displayed with its corresponding statistics listed from left to right, with one record per variable. All of the variables used in the example are analysis variables. No CLASS variables are used.
When you include additional statistics in the output data set, it also changes the shape of the original default output data set. If you have requested non-default statistics and want to return to an output data set like the default, please see Sample 42381: Reshape PROC MEANS output when requesting non-default statistics.
Please note that in SAS® 9.3 an enhancement to the MEANS and SUMMARY procedure statements is available. STACKODSOUTPUT eliminates the need to post-process the data set created by either procedure. The option affects the output data set created with the ODS OUTPUT statement, which more closely mimics the default table created by PROC MEANS or PROC SUMMARY with the PRINT option.
Sample Code 2 on the Full Code tab illustrates this new option. This option is discussed in the SAS Online Documentation.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Sample Code 1 below uses a simple PROC TRANSPOSE of the _STAT_ variable to produce the standard-looking output that you expect to see from the MEANS procedure. The variable is displayed with its corresponding statistics listed from left to right, with one record per variable.
Sample Code 2 shows a new option available in the PROC MEANS and PROC SUMMARY statement that reshapes the ODS OUTPUT data set to eliminate the need for this TRANSPOSE procedure step.
/* Sample Code 1. This works in all SAS versions. */
/* Create a sample data set. */
data travel;
input AIR DEST & :$10. NAME :$ HOTEL;
datalines;
1500 PARIS THOMAS 712
1500 PARIS THOMAS 594
1523 FRANKFURT BECKER 284
;
run;
options orientation=landscape nodate number;
ods pdf file="allSASversions.pdf" notoc;
/* Specify the PROC MEANS OUTPUT statement to create an output data set. */
proc means data=travel missing noprint;
output out=myout(drop= _type_ _freq_);
run;
/* Print the default data set. */
/* It does not look like the procedure output. */
proc print data=myout noobs;
title 'Default Data set ';
run;
/* Perform an interim transpose of the data. */
proc transpose data=myout out=mytransp name=Variable;
id _stat_;
run;
/* The printed output now looks like the procedure output. */
proc print data=mytransp noobs;
title 'Print data set to look like MEANS procedure output';
run;
ods pdf close;
title;
footnote;
/* Sample Code 2. This works in SAS 9.3 and higher. */
options orientation=landscape nodate number;
ods pdf file="new_for_9.3.pdf" notoc;
ods noptitle;
title "Default table from the MEANS procedure";
ods output summary=odsdsn(drop=_control_);
proc means data=sashelp.cars n nmiss min max mean stackodsoutput;
class origin;
output out=nonods;
run;
title "Original output data set from the OUTPUT statement";
proc report data=nonods nowd;
run;
title "ODS OUTPUT data set with STACKODSOUTPUT option added";
proc report data=odsdsn nowd ;
run;
title "PROC REPORT enhancement to the ODS OUTPUT data set with STACKODSOUTPUT option added";
proc report data=odsdsn nowd spanrows ;
define origin / order;
define nobs / order;
run;
ods _all_ close;
title;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
| Type: | Sample |
| Date Modified: | 2012-03-19 10:03:01 |
| Date Created: | 2011-12-20 14:55:00 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | Base SAS | Windows 7 Ultimate x64 | ||
| Windows Millennium Edition (Me) | ||||
| Windows 7 Professional x64 | ||||
| Windows 7 Ultimate 32 bit | ||||
| Windows 7 Home Premium 32 bit | ||||
| Windows 7 Home Premium x64 | ||||
| Windows 7 Professional 32 bit | ||||
| Windows 7 Enterprise 32 bit | ||||
| Windows 7 Enterprise x64 | ||||
| Microsoft Windows Server 2008 for x64 | ||||
| Microsoft Windows XP Professional | ||||
| Microsoft Windows Server 2003 for x64 | ||||
| Microsoft Windows Server 2008 | ||||
| Microsoft Windows Server 2003 Standard Edition | ||||
| Microsoft Windows Server 2003 Datacenter Edition | ||||
| Microsoft Windows Server 2003 Enterprise Edition | ||||
| Microsoft Windows 2000 Server | ||||
| Microsoft Windows 2000 Professional | ||||
| Microsoft Windows NT Workstation | ||||
| Microsoft Windows 2000 Datacenter Server | ||||
| OS/2 | ||||
| Microsoft Windows 95/98 | ||||
| Microsoft Windows 2000 Advanced Server | ||||
| Microsoft Windows XP 64-bit Edition | ||||
| Microsoft® Windows® for x64 | ||||
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
| OpenVMS VAX | ||||
| Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
| z/OS | ||||
| Z64 | ||||
| Teradata on Linux | ||||
| Solaris for x64 | ||||
| Tru64 UNIX | ||||
| OpenVMS on HP Integrity | ||||
| Solaris | ||||
| Linux for x64 | ||||
| Linux on Itanium | ||||
| OpenVMS Alpha | ||||
| IRIX | ||||
| Linux | ||||
| AIX | ||||
| HP-UX | ||||
| HP-UX IPF | ||||
| 64-bit Enabled Solaris | ||||
| ABI+ for Intel Architecture | ||||
| 64-bit Enabled AIX | ||||
| 64-bit Enabled HP-UX | ||||
| Windows Vista | ||||
| Windows Vista for x64 | ||||




