Since entering (as prior PROC MEANS)
has no effect with TTEST, one brute force way is to convert the label to
a "valid" variable name, rename the respective variables in a new
dataset, and then run that new dataset thru TTEST (or another PROC).
Limitations are the max length of a variable name of 32, the need to
remove spaces from the label (or find a way to insert the underscore in
their place), and that the label must start with a letter to be a valid
DATA _null_ ; set scores;
LENGTH n1 n2 $32 ; * max length of variable name;
IF (_n_=1) then
n1=COMPRESS(vlabel(score),' '); * extract labels and remove spaces;
call symput("sc", trim(n1)); * put 'spaceless' label in macro
%put &sc &gnd;
* work with a copy of the dataset;
DATA sc; SET scores; run;
rename gender=&gnd score=≻
proc print data=sc; run;
proc ttest data=sc;
Note, there is an option
that deals with entering spaces into "valid" variable names, but have
found it risky to use.
University of Oregon
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Monday, February 04, 2008 11:02 AM
Subject: Getting TTEST (and other PROCS) to print variable labels
instead of names
I looked at the documentation for TTEST and googled a bit, but didn't
see a way to get PROC TTEST to print variable labels instead of variable
names. People at my current place of employment are fond of giving
variables names like VAR1, and then using labels.
They've been collecting data for 30 years, so they aren't going to
change (and there's no way to change all the data sets they have).
So, is there a way to get PROC TTEST to do this?
Is there general guidance on how to make SAS PROCs print labels instead
of variable names?
TIA as always