I have a SAS dataset with some variable, and I wish to run PROC TABULATE for each one of them. I wrote a macro to do that, but the macro prints the name of the variables, while I would like to print their label, and I do not know how to change that. My macro is:
%macro Frequency(data, variable);
title2 "Frequency Distribution of &variable";
proc tabulate data = &data;
class treatment &variable;
table (treatment = '' all),(&variable = '' all)*(n*f=8. rowpctn='%'*f=8.1)/box = "Treatment Group/&variable";
run;
title2;
%mend Frequency;
The problem is, that some variables has a label of more than one word, and I can't get an output with a title aaa_hhh, it has to be properly aaa hhh.
Another idea I had was to transpose the data into a "long" format, and to use the "by" word to run the tabulation by variable, however, this failed too, since I want the variable name in the box, and "ByVal1" doesn't support that option. Can you please assist me here? Thank you.