|
Peter,
Since entering (as prior PROC MEANS)
OPTION label;
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
variable name.
DATA _null_ ; set scores;
LENGTH n1 n2 $32 ; * max length of variable name;
IF (_n_=1) then
DO;
n1=COMPRESS(vlabel(score),' '); * extract labels and remove spaces;
n2=COMPRESS(vlabel(gender),' ');
call symput("sc", trim(n1)); * put 'spaceless' label in macro
variable;
call symput("gnd",trim(n2));
END;
stop;
run;
%put &sc &gnd;
* work with a copy of the dataset;
DATA sc; SET scores; run;
*rename variables;
proc datasets;
modify sc;
rename gender=&gnd score=≻
run; quit;
proc print data=sc; run;
proc ttest data=sc;
class &gnd;
var &sc.;
run;
Note, there is an option
OPTIONS validvarname=any;
that deals with entering spaces into "valid" variable names, but have
found it risky to use.
Robin High
University of Oregon
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Peter Flom
Sent: Monday, February 04, 2008 11:02 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Getting TTEST (and other PROCS) to print variable labels
instead of names
Hi
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
Peter
|