0
votes

I know I can use the command KEYLABEL in PROC TABULATE to specify a custom label for the statistic names i.e:

KEYLABEL N = ' ' ALL = "Total" PCTN = "Percent" SUM = "Total";

It doesn't work with PROC MEANS. Is there an equivalent command? Can I use a workaround to do this? I'm running the SAS program and generating the Latex markeup automatically from that, so I need to change the names of the N, SUM, MEAN, MEDIAN, MIN, MAX columns reported in the PROC MEANS command if possible.

Thanks.

1
If you don't get a good answer here, I highly recommend asking on the SAS Listserv ([email protected]). One of the users is highly skilled at *tex output and may well have encountered this in the past. I'll look around at SUGI papers he's written and see if any of them seem to help. - Joe

1 Answers

1
votes

I don't think you can change the automatic variable labels in PROC MEANS to something custom, unfortunately. You can label the variable:

proc means data=sashelp.class;
var age;
label age="Child's Age";
class name;
output out=classmean sum=;
run;

You can use AUTOLABEL to automatically append (default) labels:

proc means data=sashelp.class;
var age;
label age="Child's Age";
class name;
output out=classmean sum= n= /autoname autolabel;
run;

But I don't think you can control it further than that. The easiest solution I can imagine is writing a macro to do it using PROC DATASETS [taking the known variable names and assigning them labels based on those names]. I don't know what you need to make them, but it's not terribly difficult to do. Something like this (the proc sql in particular will vary significantly based on your program).

%macro relabel(var=);
label &var._n = "&var. Count";
*... more of these ...;
%mend relabel;

proc sql;
select cats('%relabel(var=',name,')') into :rellist separated by ' ' 
  from dictionary.columns
  where memname='MYDATASET' and libname='WORK' and *criteria to determine in proc means*;
quit;
proc datasets;
&rellist.
quit;