1
votes

I am wondering if it is possible to create unique labels in proc report for each column generated under an across variable. E.g., say I have the following data:

data report;
    input ARM GRADE1 GRADE2 TOTAL N;
    datalines;
1 0 1 1 2
1 1 0 1 2
2 1 2 3 3
2 1 1 2 3
2 0 1 1 3
;
run;

Here I have 2 arms, with the count of each grade and then the total. I have also included N, which is the number of patients per arm. I would like to use proc report with ARM as an across variable like this:

proc report data=report;
  column ARM, (GRADE1 GRADE2 TOTAL);
  define ARM / across;
run;

But, I would like to somehow make the Total columns appear as Total (N = 2) and Total (N = 3) under ARM=1/ARM=2 respectively. Is this possible? Or is there an easier way to set up my data so I can accomplish this?

1

1 Answers

1
votes

Technique 1

You can report the count and sum by stacking them in a subordinate dimension under total. Not exactly the output desired by questioner, but simple and easy.

proc report data=report;
  column ARM, (GRADE1 GRADE2 TOTAL,(N SUM));
  define ARM / across;
run;

Output
enter image description here


Technique 2

Output as desired
enter image description here

A DATA Step based transposition into a categorical form will rearrange the data that allows for the 'column name' to be presented as data. The REPORT option NOCOMPLETECOLS is used to prevent columns not associated with a specific N=nnn.

The column header is set to ' ' to hide the column name, because the original column name was turned into data during the transposition.

Example:

data report;
    input ARM GRADE1 GRADE2 TOTAL N;
    rownum + 1;
    datalines;
1 0 1 1 2
1 1 0 1 2
2 1 2 3 3
2 1 1 2 3
2 0 1 1 3
;
run;

* transpose the data, with a special name construct for the total;
data reportT;
  set report;
  by rownum arm;
  length name $40;
  name = 'Grade1'; value = Grade1; output;
  name = 'Grade2'; value = Grade2; output;
  name = cats('Total (n=', n, ')'); value=total; output;
  keep arm name value;
run;

ods html file='report.html' style=plateau;

proc report data=reportT NOCOMPLETECOLS;
  column arm, name, value;
  define arm / across;
  define name / ' ' across;
  define value / ' ' ;
run;

ods html close;