0
votes

I am reporting a large listing of values for subgroups of my data. I have the data in the form I currently want and just have a cosmetic change to make. I am trying to find a way to print the value of the subgroup on the first line of each page but empty for the rest of the values.

I have tried doing this multiple ways using an the ID option in define, using a compute after block, compute after _page_, a pagination column and by using a by statement but I can't maintain the structure of my data with these methods.

Here is some example data and basic proc report:

/* basic data */
data test;
  input ID $ variable1 $ variable2 $;
  datalines;
A Lemon Yellow
A Orange Red
A Lemon Blue
A Apple Green
A Lemon Yellow
A Orange Red
A Lemon Blue
A Apple Green
A Lemon Yellow
A Orange Pink
A Lemon Blue
A Apple Red
B Lemon Yellow
B Orange Red
B Lemon Blue
B Apple Green
B Lemon Yellow
B Orange Red
B Lemon Blue
B Apple Green
B Lemon Yellow
B Orange Pink
B Lemon Blue
B Apple Red
;
run;

/* output several times to cover multiple pages */
data test2;
set test;
if id = "A" then do;
output;
output;
output;
end;

output;
run;

/* proc report */
ods pdf;
proc report data = test2  nocenter nowd ;

define ID / order id ;
define variable1 / display;
define variable2 /display;

compute after ID;
  line '';
  endcomp;

run;
ods pdf close;

So in this example the values for A and B run over multiple pages. I want A and B to appear on their first observation and the first observation on a new page.

Any help is as always appreciated.

1
What is your output file type PDF, RTF, text, PowerPoint, Excel?Reeza
Output is PDF as in the test proc reportAndrew Haynes
Try a BY group with a title using the BYVAL.Reeza

1 Answers

0
votes

It's not clear what precisely you want, but here are a few options.

One: compute before _page_. That lets you put it in the table as the first cell, but looks a little ... weird.

Two: define a by group. That prints it at the start of the by group.

*COMPUTE BEFORE _PAGE_ option;

ods pdf file="c:\temp\test.pdf";
proc report data = test2  nocenter nowd ;

define ID / order id ;
define variable1 / display;
define variable2 /display;

compute after ID;
  line '';
  endcomp;

compute before _page_;  *prints ID here - can add more text if you want;
  line ID $;
endcomp;

run;
ods pdf close;


*BY groups;

ods pdf file="c:\temp\test.pdf" startpage=never;
proc report data = test2  nocenter nowd ;
by id;                                    *adding by group here;
define ID / order id ;
define variable1 / display;
define variable2 /display;

compute after ID;
  line '';
  endcomp;

run;
ods pdf close;