BookmarkSubscribeRSS Feed
Eva
Quartz | Level 8 Eva
Quartz | Level 8
Hello!

I have a proc report with group, across and an analysis variable. Furthermore there is a break and an rbreak. All this works well. Now I'd like to add an additional row after each break. Yet I don't want to do this with the line statement but in a way so that there are all individual cells for each column like in a break statement. You can think of this wished-for line like a break statment which however contains any computation that I want and not only a summary.

Here is the code for the part that works:


proc report data=work.mydata;

column mygroupfield1 mygroupfield2 myacrossfield myvalues;

define mygroupfield1 / group;
define mygroupfield2 / group;
define myacrossfield / across;
define myvalues / analysis sum;

break after mygroupfield2 / summarize;
rbreak after / summarize;

run;


The new row which I want to insert should come after the break of mygroupfield2.

Can anybody help?

Best regards,
Eva
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
Hi:
As you have discovered the LINE statement produces one row that spans all the columns in the report.

One method to produce the creation of extra summary lines is shown in this most excellent paper:
http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf
(on pages 7 and 8, in the section entitled "Adding Multiple Summary Rows")

cynthia
Cynthia_sas
Diamond | Level 26
Hi:
As you have discovered the LINE statement produces one row that spans all the columns in the report.

One method to produce the creation of extra summary lines is shown in this most excellent paper:
http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf
(on pages 7 and 8, in the section entitled "Adding Multiple Summary Rows")

cynthia
Eva
Quartz | Level 8 Eva
Quartz | Level 8
Dear Cynthia,

thanx for your great answer. Still there are two things which don't work.

First: the newly computed "summary" line appears before the other break. I'd like to have that after the other break. Changing orders in the column statement however doesn't do the trick as the computed summary line then appears somewhere completely different (after each change of value for the second group variable - mygroupfield2).

Second: doing any computation doesn't work either. It is ignored and the same values as in the other break statement are displayed.

Here is my code:

/* add the helping variable to later display the computed break line */
data work.mydata;

set work.mybasedata;

myhelp = 1;

run;

proc report data=work.mydata;

column mygroupfield1 myhelp mygroupfield2 myacrossfield myvalues;

define mygroupfield1 / group;
define myhelp / group noprint;
define mygroupfield2 / group;
define myacrossfield / across;
define myvalues / analysis sum;

break after mygroupfield1 / summarize;
break after myhelp / summarize;
rbreak after / summarize;

compute after myhelp;
mygroupfield1 = 'percentage';
myvalues = (mysum / mysupersum) * 100;
endcomp;

compute before mygroupfield1;
mysum = myvalues.sum;
endcomp;

compute before;
mysupersum = myvalues.sum;
endcomp;

run;

Usind myvalues.sum in the compute after myhelp doesn't work unfortunately. I get the error
ERROR: The variable type of MYVALUES.SUM is invalid in this context.
ERROR: Illegal reference to the array MYVALUES.SUM.

Best wishes
Eva

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2993 views
  • 0 likes
  • 2 in conversation