Sample 48278: Use the VALIDVARNAME=ANY system option to display only variable labels in PROC FREQ results
Users can modify the CrossTabFreqs template to display only labels in PROC FREQ CrossTabs results. The sample program on the
Full Code tab presents an alternative method for users who do not want to modify the template. The VALIDVARNAME=ANY system option enables you to create new data set variables whose names are the labels for the existing variables. The new variables can then be used in the PROC FREQ step.
Note of caution:
SAS variable names cannot exceed 32 characters in length. If a variable label exceeds 32 characters, the sample code generates an error.
A sample showing the method for modifying the Base.Freq.CrossTabFreqs template to display only labels can be found in SAS Note 48277.
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 uses the VALIDVARNAME=ANY system option to create new data set variables whose names are the labels for the existing variables. The new variables can then be used in the PROC FREQ step.
/* Create a data set that adds variable labels */
data tempclass;
set sashelp.class;
label age='Age in Years'
sex='Student Gender';
run;
data _null_;
set tempclass;
call symput('age',vlabel(age));
call symput('sex',vlabel(sex));
run;
%put &age;
%put &sex;
options validvarname=any;
data tempclass;
set tempclass;
"&age"n=age;
"&sex"n=sex;
run;
proc print;
run;
ods html file='temp.html';
/* Specify the variable names using a name literal */
proc freq data=tempclass;
tables "&age"n * "&sex"n / norow nocol;
run;
ods html close;
/* Reset the VALIDVARNAME= option to its default value */
options validvarname=V7;
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.
This sample illustrates how to display only variable labels in PROC FREQ two-way tables without modifying the Base.Freq.CrossTabFreqs template.
Date Modified: | 2012-11-07 09:33:07 |
Date Created: | 2012-10-26 09:14:26 |
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft Windows XP 64-bit Edition | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft® Windows® for x64 | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 for x64 | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft Windows Server 2008 for x64 | 9.21_M1 | | 9.2 TS2M0 | |
Microsoft Windows XP Professional | 9.21_M1 | | 9.2 TS2M0 | |
Windows Vista | 9.21_M1 | | 9.2 TS2M0 | |
Windows Vista for x64 | 9.21_M1 | | 9.2 TS2M0 | |
64-bit Enabled AIX | 9.21_M1 | | 9.2 TS2M0 | |
64-bit Enabled HP-UX | 9.21_M1 | | 9.2 TS2M0 | |
64-bit Enabled Solaris | 9.21_M1 | | 9.2 TS2M0 | |
HP-UX IPF | 9.21_M1 | | 9.2 TS2M0 | |
Linux | 9.21_M1 | | 9.2 TS2M0 | |
Linux for x64 | 9.21_M1 | | 9.2 TS2M0 | |
OpenVMS on HP Integrity | 9.21_M1 | | 9.2 TS2M0 | |
Solaris for x64 | 9.21_M1 | | 9.2 TS2M0 | |