title: SAS variable labels in macro
body: <p>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:</p>
  
  <pre><code>%macro Frequency(data, variable);
  title2 "Frequency Distribution of &amp;variable";
  proc tabulate data = &amp;data;
      class treatment &amp;variable;
      table (treatment = '' all),(&amp;variable = '' all)*(n*f=8. rowpctn='%'*f=8.1)/box = "Treatment Group/&amp;variable";
  run;
  title2;
  %mend Frequency;
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>