Sample 48287: Use the CHARTYPE option in PROC MEANS to get binary representation of the _TYPE_ variable
You can specify the CHARTYPE option in the PROC MEANS statement to get a character representation of the binary value of the _TYPE_ variable in the output data set. Click the
Full Code tab to see an example.
The macro in the sample code shows how you can post-process the PROC MEANS output data set to create a data set variable containing the list of class variables that contribute to each observation.
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 sample code below illustrates how to use the CHARTYPE option in PROC MEANS to get binary representation of the _TYPE_ variable.
/* Create a sample data set */
data test;
length a b c d $ 8;
do a='yes','no';
do b='Moe','Larry','Curly';
do c='sas','quatch';
do i=1 to 4;
do j=1 to int(ranuni(i)*4) +1;
x=int(ranuni(j)*13) +1;
y=int(ranuni(x)*13) +1;
z=int(ranuni(y)*13) +1;
output;
end;
end;
end;
end;
end;
drop i j;
run;
%let classlist=a b c;
proc means data=test chartype noprint;
class &classlist;
var x ;
output out=outsum sum= mean= / autoname;
run;
proc print data=outsum;
run;
%macro findtypes;
%let counter=%sysfunc(countw(&classlist,' '));
%put &counter;
data final;
retain &classlist _TYPE_ classvars;
set outsum;
length classvars classchk $ 25;
classvars='';
classchk=symget('classlist');
%do i=1 %to &counter;
if substr(_type_,&i,1)='1'
then classvars=catx(' ',classvars,scan(classchk,&i,' '));
%end;
drop classchk;
run;
%mend;
%findtypes
ods html file='temp.html';
proc print data=final;
run;
ods html close;
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.
You can specify the CHARTYPE option in the PROC MEANS statement to get a character representation of the binary value of the _TYPE_ variable in the output data set.
| Date Modified: | 2012-11-07 09:48:08 |
| Date Created: | 2012-10-26 15:38:40 |
Operating System and Release Information
| SAS System | Base SAS | Aster Data nCluster on Linux x64 | | |
| DB2 Universal Database on AIX | | |
| DB2 Universal Database on Linux x64 | | |
| Greenplum on Linux x64 | | |
| Netezza TwinFin 32bit blade | | |
| Netezza TwinFin 32-bit SMP Hosts | | |
| Netezza TwinFin 64-bit S-Blades | | |
| Netezza TwinFin 64-bit SMP Hosts | | |
| Teradata on Linux | | |
| z/OS | | |
| Z64 | | |
| 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 Pro | | |
| 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 for x64 | | |
| Microsoft Windows Server 2012 | | |
| 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 | | |
| ABI+ for Intel Architecture | | |
| 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 | | |