Hi:
Ah, you did not show an ACROSS situation in your original posting, which is why my example did not work for you.
...when you use ACROSS items, the naming convention changes for how you refer to items in the COMPUTE block. PROC REPORT assigns -internal- absolute column names, such as _c1_, _c2_, _c3_ to every across report item on a report row, and when you have items nested, such as you now show, you cannot refer to your variable as just REPTOT. You will have REPTOT under YEAR1, PRODUCTGROUP1, and REPTOT under YEAR1, PRODUCTGROUP2 and REPTOT under YEAR2, PRODUCTGROUP1, etc, etc.
If you look in the PROC REPORT documentation and examine the output from the program below, you should be able to get an idea of how this works and how your COMPUTE block would have to change.
Especially useful is the fact that you can use OUT= to reveal the absolute names that PROC REPORT assigns internally. So just as my code is showing the XXX variable as _C5_, _C8_ and _c11_, once you get your nestings arranged the way you want, you may find that the absolute column name for REPTOT might be _c4_, _c6_, _c8_ or _C10_ (depending on how many year/product combos you have).
You will also probably find that you need total_scripts to be nested under each year and product group, too. It doesn't make sense that your total_scripts would be outside the nesting. But you'll have to decide that based on what your real data looks like.
It is hard, but not impossible to figure the absolute column names. You need several pieces of information -- how many report items appear BEFORE the across variable(s) and how many unique combos of across item(s) there are. Then you should notice from my examples, that the naming falls into a pattern. (And if you search the doc, you will find some algorithms for how to figure what the absolute column names will be.) But the above is just a guess based on what your data might actually look like and whether I was right about every year/productgroup combination having a separate total_script value.
At any rate, if you look at the structure of SASHELP.PRDSALE and then at these 2 examples, they should give you an idea of how absolute column names work. SASHELP.PRDSALE has only 2 years and 2 values for PRODTYPE. So my total possible ACROSS unique combinations are 4 possible values:
[pre]
--------1993-------|--------1994-------|
FURNITURE | OFFICE |FURNITURE | OFFICE |
[/pre]
Each year has 2 possible values for PRODTYPE. So NOW, the absolute column names will be set on how many items are nested under each unique YEAR/PRODTYPE combinations and how many report items come BEFORE the first ACROSS variable. The program contains 2 separate examples and I haven't used NOPRINT to hide anything. You can see that the absolute column names in the first example are different than the absolute column names in the second example. This is because in the first example, I have 3 columns nested under each unique combination of YEAR/PRODTYPE and in the second example, I only have 2 columns nested under each unique combination of YEAR/PRODTYPE.
The 2nd example might be closer to what you're trying. I suggest you really take the time to read up on how PROC REPORT processes and uses ACROSS variables to understand what you want to code. You will not be able to just cut and paste my code into your PROC REPORT -- you'll have to adjust it based on your -real- data and the number of unique combinations you have going ACROSS in your data.
cynthia
[pre]
ods html file='c:\temp\show_across.html' style=sasweb;
proc report data=sashelp.prdsale nowd out=whatcols;
title '1a) with ACROSS';
column country region year,prodtype,(actual predict xxx) ;
define country / group;
define region / group;
define year / across 'Based on Year and ProdType Value';
define prodtype / across ' ';
define actual / sum;
define predict / sum;
define xxx / computed;
rbreak after / summarize;
compute xxx;
_c5_ = _c3_ - _c4_;
_c8_ = _c6_ - _c7_;
_c11_ = _c9_ - _c10_;
_c14_ = _c12_ - _c13_;
endcomp;
run;
proc print data=whatcols;
title '1b) What do Absolute Columns Look Like?';
run;
proc report data=sashelp.prdsale nowd out=whatcols2;
title '2a) with conditional logic';
column country region year,prodtype,(actual reptot) ;
define country / group;
define region / group;
define year / across 'Based on Year and ProdType Value';
define prodtype / across ' ';
define actual / sum f=dollar12.;
define reptot / computed f=dollar12.;
rbreak after / summarize;
compute reptot;
if region = 'EAST' and country = 'CANADA' then do;
_c4_ = .;
_c6_ = .;
_c8_ = .;
_c10_ = .;
end;
else do; /* all other conditions */
_c4_ = _c3_;
_c6_ = _c5_;
_c8_ = _c7_;
_c10_ = _c9_;
end;
if _break_ = '_RBREAK_' then do;
country = 'Total';
_c4_ = _c3_;
_c6_ = _c5_;
_c8_ = _c7_;
_c10_ = _c9_;
end;
endcomp;
run;
proc print data=whatcols2;
title '2b) Different Absolute Columns Look Like?';
run;
ods _all_ close;
title; footnote;
[/pre]