BookmarkSubscribeRSS Feed
NN
Quartz | Level 8 NN
Quartz | Level 8

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

3 REPLIES 3
Cynthia_sas
Diamond | Level 26

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
Ksharp
Super User

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

NN
Quartz | Level 8 NN
Quartz | Level 8

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..

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 5375 views
  • 6 likes
  • 3 in conversation