BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
1 REPLY 1
Cynthia_sas
SAS Super FREQ
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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 754 views
  • 0 likes
  • 2 in conversation