Hi:
Well, you have several things happening that are all related to how PROC REPORT operates:
1) PROC REPORT works from LEFT to RIGHT placing items on each report ROW -- so that was a good idea to have a PRE_MAIN variable to influence the breaking for MAIN. But, stay tuned, this LEFT to RIGHT operation is going to come back down below.
2) NOPRINT means NOPRINT for EVERYTHING so, since PRE_MAIN is a NOPRINT item...when you do this in your COMPUTE block:
[pre]
compute after PRE_MAIN;
PRE_MAIN ='SubTotal';
line='';
endcomp;
[/pre]
You are assigning the string 'SubTotal' to a NOPRINT variable -- so you will not see anything. There's no problem with the LINE statement because the LINE statement executes after everything in the COMPUTE block executes and writes a blank line to the report.
3) PROC REPORT makes an automatic variable called _BREAK_ which you can test inside COMPUTE blocks. It holds the name of the variable or report item if a report row is coming from a BREAK or RBREAK statement. So, for example, on a "regular" report row, _BREAK_ would be blank, but at the break for PRE_MAIN, the value of _BREAK_ would be PRE_MAIN (the name of the variable). Again, stay tuned, this will come back later.
4) It is redundant to have "group order" in your DEFINE statement. A usage can only be 1 thing -- either GROUP or ORDER. (This is the list of possible usages -- GROUP, ORDER, ACROSS, DISPLAY and ANALYSIS or a STATISTIC name which implies a usage of ANALYSIS). In your case, you are getting an ORDER usage because that is the last usage listed in the DEFINE statement, but if you carefully review the output from this SASHELP.CLASS code, you can see that there -is- a difference in the 2 USAGES.
Test program to illustrate the difference between GROUP and ORDER usage:
[pre]
proc report data=sashelp.class nowd;
title '2 usages -- last specified will be used -- see 19 rows';
column sex age height;
define sex / group order ;
define age / sum;
define height / sum;
run;
proc report data=sashelp.class nowd;
title 'Only GROUP usage -- get 2 summarized report rows';
column sex age height;
define sex / group;
define age / sum;
define height / sum;
run;
proc report data=sashelp.class nowd;
title 'Only ORDER usage -- get 19 report rows';
column sex age height;
define sex / order;
define age / sum;
define height / sum;
run;
[/pre]
You might have meant to type:
[pre]
define Pre_MAIN / group order=data noprint ;
define MAIN/group order=data;
[/pre]
which would be OK, but just group order might get you the wrong report down the road -- so it would be better to fix this now.
Now, the -visible- item on the report row is MAIN, not PRE_MAIN. So you want the value for MAIN to change at the break for PRE_MAIN. But because PROC REPORT works from LEFT to RIGHT and because PRE_MAIN appears before MAIN in the COLUMN statement, you cannot change MAIN in the COMPUTE block for PRE_MAIN, but you can change the value for MAIN in a COMPUTE block for MAIN -- but you will have to test the value of the _BREAK_ variable:
[pre]
compute MAIN;
*** test the automatic _BREAK_ variable;
if upcase(_break_) = "PRE_MAIN" then do;
MAIN = 'SubTotal';
end;
endcomp;
[/pre]
So that should give you some things to work on. First, I'd recommend that you decide whether you want GROUP or ORDER for PRE_MAIN and MAIN and fix that and then move forward and change the COMPUTE blocks.
A good rule of thumb for how to decide between GROUP and ORDER is this:
--ORDER usage produces a detail report where you have 1 report row for every observation in your dataset or subset of data. So, for example, SASHELP.CLASS has 19 observations. With a usage of ORDER, I will see at least 19 report rows. If I have breaks, then the break lines will be added to the 19 detail rows.
--GROUP usage produces a summarized report, where 1 report row represents the summary of a GROUP of observations. So, for example, SASHELP.CLASS has 19 observations, but only 2 genders represented -- male and female. If I set the usage for the SEX variable to be GROUP, then I will see at least 2 report rows (one summarized row for MALE and one summarized row for FEMALE) -- If I have breaks, then the break lines will be added to the 2 grouped rows.
cynthia