BookmarkSubscribeRSS Feed
Siddhartha
Calcite | Level 5
Could any tell me the major differences between Proc Report and Proc Tabulate.
And also how could i highlight a cell using proc report and proc tabulate.

Thanks & Regards,
Siddhartha
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Proc Report and Proc Tabulate can both be used to create summary tables. Proc Report has the added feature of being able to create detail tables, as well. Proc Report has some of the power of a DATA step program, in that REPORT allows you to calculate a new report item (like BONUSAMT) in a COMPUTE block -- something which TABULATE will not do.

It's easier, or maybe just different, to get many crossings in the row and column dimension with TABULATE. TABULATE produces 3 dimensions of reports -- PAGE, ROW and COLUMN dimension using a TABLE statement along with a CLASS and VAR statement. REPORT does everything with a COLUMN statement and DEFINE statements, along with COMPUTE blocks.

With PROC REPORT, you can write lines between groups (such as "Good job on Sales this quarter, Department 99" or "Focus on improving sales, Department 45") with the LINE statement-- whereas with TABULATE, you cannot do this.

The following code example shows approximately the same table for both REPORT and TABULATE, the basic highlighting of PREDICT and ACTUAL is done, in this case, with a user-defined format. With PROC REPORT, you could also highlight a cell, or an entire row using the CALL DEFINE statement, too.

cynthia
[pre]
proc format;
value salef 21000-22000 = 'yellow'
22000<-23000 = 'pink';
run;

ods listing close;

ods html file='hilight.html' style=sasweb;

title 'Proc Report';
proc report data=sashelp.prdsale nowd;
column country product region,('Sales' predict actual);
define country /group;
define product /group;
define region /across ;
define predict / sum 'Predicted'
style(column)={background=salef.};
define actual /sum 'Actual'
style(column)={background=salef.};
rbreak after / summarize;
run;

title 'Proc Tabulate';
proc tabulate data=sashelp.prdsale f=dollar12.2;
class country region product;
var predict actual ;
table country * product all,
region*Sum*(predict actual)*{s={background=salef.}};
keylabel Sum='Sales'
All='Total';
run;
ods html close;
[/pre]
deleted_user
Not applicable
Question...

How do you format the ALL='Total' statement in your proc tabulate?

I have ALL='Total Congestion Revenue' but cannot figure out how to adjust the font_size. Thanks for any help. I'm sure this is a drop in a bucket for some around here. I am new to this...

B Message was edited by: BS_CISO
Cynthia_sas
SAS Super FREQ
Hi:
There are 2 different ways to change the ALL summary:
1) change the header for "all"
2) change the data cells for the summary

[pre]
table country * product all *{s={font_size=16pt background=yellow}},
region*Sum*(predict actual)*{s={background=salef.}}
/ style_precedence=row;
keylabel Sum='Sales'
All='Total';
keyword ALL / style={background=purple foreground=white};
[/pre]

The KEYWORD statement will change the style of the header label for ALL and the style in the table statement (crossed with ALL) will change the data cells in the summary produced by ALL. In addition, since the style crossing happens in the row dimension, you want the style of the row to take precedence over the style of the column -- for the cell where row and column intersect.

cynthia
jaiganesh
Obsidian | Level 7

Hello,

 

 

I'm a learner of SAS.

 

Can you please provide the data set you used for explaining this both examples.

 

 

Regards,

Jaiganesh

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 14423 views
  • 4 likes
  • 4 in conversation