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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 566 views
  • 0 likes
  • 2 in conversation