The SAS Output Delivery System and reporting techniques

Break and Rbreak Before

Reply
Regular Contributor
Regular Contributor
Posts: 166

Break and Rbreak Before

Hi,

I ran two proc reports

first one with a break after and rbreak after

  PROC REPORT DATA=SASHELP.CLASS;

  COLUMN SEX NAME AGE HEIGHT;

  DEFINE SEX / GROUP;

  DEFINE NAME / GROUP;

  DEFINE AGE / SUM;

  DEFINE HEIGHT / SUM;

  BREAK AFTER SEX / SUMMARIZE;

  RBREAK AFTER / SUMMARIZE;

  COMPUTE AFTER SEX;

  CALL DEFINE (_ROW_,"STYLE","STYLE=[BACKGROUND = GREEN]");

  SEX = 'S';

  ENDCOMP;

  COMPUTE AFTER;

  CALL DEFINE (_ROW_,"STYLE","STYLE=[BACKGROUND = RED]");

  SEX = 'T';

  ENDCOMP;

  RUN;

And the second one with a break before and rbreak before.

  PROC REPORT DATA=SASHELP.CLASS;

  COLUMN SEX NAME AGE HEIGHT;

  DEFINE SEX / GROUP;

  DEFINE NAME / GROUP;

  DEFINE AGE / SUM;

  DEFINE HEIGHT / SUM;

  BREAK BEFORE SEX / SUMMARIZE;

  RBREAK BEFORE / SUMMARIZE;

  COMPUTE BEFORE SEX;

  CALL DEFINE (_ROW_,"STYLE","STYLE=[BACKGROUND = GREEN]");

  SEX = 'S';

  ENDCOMP;

  COMPUTE BEFORE;

  CALL DEFINE (_ROW_,"STYLE","STYLE=[BACKGROUND = RED]");

  SEX = 'T';

  ENDCOMP;

  RUN;

Can someone please guide as to why the background and formatting change in the second report..

If you could direct to some sas notes that would help too..

Thanks

SAS Super FREQ
Posts: 8,868

Re: Break and Rbreak Before

Hi:

  I guess I don't understand your question. The BEFORE or AFTER in the BREAK and RBREAK statements determine where the subtotals and/or totals are going to placed in the output report. With the BEFORE location, all the summary lines come BEFORE (or above) the group to which they refer or at the top of the report. On the other hand, the AFTER location causes all the summary lines to appear AFTER (or at the bottom) of the group to which they refer or at the bottom of the report.

  This is exactly the same behavior that I observe in your output. Did you have some other expectation? I am attaching a screen shot of the output produced by your code (but with fewer obs -- so the 2 reports could appear side by side). I put arrows on the screenshot to show exactly which COMPUTE block was responsible for the corresponding summary lines on the report.

cynthia

Message edited & corrected typo


rbreak_question.jpg
Super User
Posts: 10,041

Re: Break and Rbreak Before

Maybe it is the reason that output order of proc report is different. You should open a track with Technical Support.

But I would not code like yours, I will code like:

ods html file='c:\x2.html' style=sasweb;

PROC REPORT DATA=SASHELP.CLASS nowd ;
  COLUMN SEX NAME AGE HEIGHT;
  DEFINE SEX / GROUP;
  DEFINE NAME / GROUP;
  DEFINE AGE / SUM;
  DEFINE HEIGHT / SUM;
  BREAK BEFORE SEX / SUMMARIZE;
  RBREAK BEFORE / SUMMARIZE;
  COMPUTE  SEX;
  if upcase(_break_) eq 'SEX' then do; CALL DEFINE (_ROW_,"STYLE","STYLE=[BACKGROUND = GREEN]");
                                   SEX = 'S';
                                   end;
   else if  upcase(_break_) eq '_RBREAK_' then do;CALL DEFINE (_ROW_,"STYLE","STYLE=[BACKGROUND = RED]");
                                    SEX = 'T';
                                    end;
  ENDCOMP;
  RUN;
  ods html close;

Ksharp

Regular Contributor
Regular Contributor
Posts: 166

Re: Break and Rbreak Before

Hi Cynthia,

The colurs for the rbreak and break that i get differ with your output. Have attached a screenshoterr1.JPG

Since you seem to be getting the correct output . Then this may be a bug..

As Ksharp said shall have to raise a track.

Thanks Ksharp... I was already using what you have suggested .. I just wanted to know why my report was incorrect when using compute before.

Thanks a lot..

Ask a Question
Discussion stats
  • 3 replies
  • 730 views
  • 6 likes
  • 3 in conversation