1
votes

I am working on PROC REPORT. Have a requirement similar to the one below. I am a little hesitant to use PROC TABULATE and want to try out PROC REPORT.

My Requirement is as below:

PRODUCT should be displayed as ACROSS variable and under each PRODUCT the SUM of SALES should be displayed by region.

proc report data=shoes; 
column sales product , region ; 
define product / across;
define region / group; * --> Need the report by REGION ; 
define sales/ analysis;
run;

But this piece of code is throwing me an error:

 ERROR: A DISPLAY or GROUP variable above or below an ACROSS variable requires that there be an ORDER, GROUP, or DISPLAY variable in the report that is not above or below an ACROSS variable.

How to do this with PROC REPORT alone. Is that really possible or I need to go for TABULATE due to this restriction?

1

1 Answers

2
votes

Your stacking order is reversed. You need to put the across column after the comma. Putting region after the comma means that you want region nested inside of product - this is probably not what you want (and why SAS can't use this code - because otherwise there's nothing to define the row).

proc report data=sashelp.shoes; 
column region sales,product; 
define product / across;
define region / group; * --> Need the report by REGION ; 
define sales/ analysis;
run;

To see what it would look like if you got it to work with what you had originally, see this table:

proc report data=sashelp.shoes; 
column sales product, region subsidiary; 
define product / across;
define region / group; * --> Need the report by REGION ; 
define sales/ analysis;
define subsidiary/group;
run;

That is entirely not what you want, I suspect. Though it is a very interesting table in its own right.