Desktop productivity for business analysts and programmers

How to generate cross reports through proc report

Reply
N/A
Posts: 0

How to generate cross reports through proc report

Hi

How to generate cross reports through proc report?
From proc report is it possible to generate cross reports.
If yes then can you give me a piece of code for example
SAS Super FREQ
Posts: 8,716

Re: How to generate cross reports through proc report

Hi:
Here's a sample that I use in class. The PROC REPORT "ACROSS" usage will produce crosstabs the way you want. So will PROC TABULATE. Compare these 2 outputs:
[pre]

proc report data=sashelp.shoes nowd;
title 'proc report Across';
where region in ('Asia', 'Canada') ;
column product region,(n sales);
define product /group;
define region /across;
define n / 'Count';
define sales /sum;
rbreak after / summarize;
compute after;
product='Total';
endcomp;
run;

proc tabulate data=sashelp.shoes f=7.0;
where region in ('Asia', 'Canada') ;
title 'TABULATE cross-tab';
class product region;
var sales;
table product all,
region * sales=' ' *(n sum*f=comma10.)
all * sales=' '*(n sum*f=comma10.);
keylabel n='Count'
sum='Total Sales'
all='Total';
run;
[/pre]

If you run the 2 procedures and compare the output, you will see that the PROC TABULATE report has a total column to the far right of the report table. This last set of columns comes from the CLASS variable ALL. This is one of the big features and advantages of PROC TABULATE. It is possible, but harder, to get a TOTAL column on the far right of the PROC REPORT output. To achieve it, you would have to use absolute column names in a compute block to get an overall total column.

The documentation for PROC REPORT and the documentation for PROC TABULATE will help you understand how to use each procedure.

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 82 views
  • 0 likes
  • 2 in conversation