Sample 51926: Use the CLASSDATA= option in PROC MEANS to limit processing to class variable
values having a minimum number of observations
The CLASSDATA= option in PROC MEANS enables you to specify a SAS® data set that contains the combinations of class variable values that must be present in the input data set. You can use the CLASSDATA= option to limit processing to class variable values having a minimum number of observations.
The example code on the Full Code tab uses the SQL procedure to create a data set that contains the number of observations for each group value, with the condition that the group should have at least 20 observations. Use that data set with the CLASSDATA= option and also specify the EXCLUSIVE option to limit the results to only those values of the GROUP variable that are in the GRPCLASS data set.
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.
The example code below uses the SQL procedure to create a data set that contains the number of observations for each group value, with the condition that the group should have at least 20 observations. Use that data set with the CLASSDATA= option and also specify the EXCLUSIVE option to limit the results to only those values of the GROUP variable that are in the GRPCLASS data set.
/* Create a sample data set */
data test;
length group $ 8;
do group='AAA','BBB','CCC','DDD','EEE';
do i=1 to 3;
do j=1 to int(ranuni(i)*14);
result=int(ranuni(j)*1234);
output;
end;
end;
end;
run;
/* Create a data set containing groups */
/* that have 20 or more observations. */
proc sql noprint;
create table grpclass
as select count(group) as count,
group as group
from test
group by group
having count(group) ge 20;
quit;
proc print data=grpclass;
run;
/* Groups AAA and EEE have fewer than 20 observations. */
/* Use the GRPCLASS data set with the CLASSDATA= option. */
proc means data=test mean maxdec=2
classdata=grpclass exclusive;
class group;
var result;
run;
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.
Date Modified: | 2014-01-14 15:35:08 |
Date Created: | 2013-12-29 13:17:42 |
Operating System and Release Information
SAS System | Base SAS | z/OS | | |
OpenVMS VAX | | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft® Windows® for x64 | | |
OS/2 | | |
Microsoft Windows 8 Enterprise 32-bit | | |
Microsoft Windows 8 Enterprise x64 | | |
Microsoft Windows 8 Pro 32-bit | | |
Microsoft Windows 8 Pro x64 | | |
Microsoft Windows 8.1 Enterprise 32-bit | | |
Microsoft Windows 8.1 Enterprise x64 | | |
Microsoft Windows 8.1 Pro | | |
Microsoft Windows 8.1 Pro 32-bit | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2003 for x64 | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows Server 2008 R2 | | |
Microsoft Windows Server 2008 for x64 | | |
Microsoft Windows Server 2012 Datacenter | | |
Microsoft Windows Server 2012 R2 Datacenter | | |
Microsoft Windows Server 2012 R2 Std | | |
Microsoft Windows Server 2012 Std | | |
Microsoft Windows XP Professional | | |
Windows 7 Enterprise 32 bit | | |
Windows 7 Enterprise x64 | | |
Windows 7 Home Premium 32 bit | | |
Windows 7 Home Premium x64 | | |
Windows 7 Professional 32 bit | | |
Windows 7 Professional x64 | | |
Windows 7 Ultimate 32 bit | | |
Windows 7 Ultimate x64 | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
Windows Vista for x64 | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |