Hi All,
May I check if I m allowed to use Proc Report to summarize multiple groups?
for eg. if i have region,country, state, zip-code, different expenses as my variables.
I would want would the report to have a listing of zip-code and then the data would be further sum up by state, country & region (all in one report)
Would appreciate your reply. Thanks!
Hi, I guess I don't understand exactly what you mean when you say: "a listing of zip-code and then the data would be further sum up by state, country & region (all in one report)" -- it's hard to visualize the report you want from this description.
Yes, PROC REPORT can produce summaries on multiple items. So can PROC MEANS, so can PROC TABULATE.
What code have you tried and what is the ultimate destination for the report (RTF, PDF, HTML?)
I have an example of multiple summaries using SASHELP.PRDSALE. Here is what it looks like for 1 country (CANADA), 2 regions (EAST and WEST), 2 divisions (CONSUMER and EDUCATION) and 5 products. This same type of summary also appears for the other 2 countries, GERMANY and U.S.A. -- but for space, I'm only showing one country here. You'd have to run the code below to see the report for all 3 countries in HTML format.
Here's the complete code that produced the report:
ods html path='c:\temp' file='sum_prdsale.html';
title;
proc report data=sashelp.prdsale spanrows;
column country region division product actual predict;
define country / group;
define region / group;
define division / group;
define product / group;
define actual / sum;
define predict / sum;
break after country / summarize style={background=lightyellow};
break after region / summarize style={background=lightgreen};
break after division / summarize style={background=verylightblue};
rbreak after / summarize style=Header;
compute after country;
country = 'C-tot';
line ' ';
endcomp;
compute after region;
region = 'R-tot';
endcomp;
compute after division;
division = 'D-tot';
endcomp;
compute after;
Country = 'Gr-tot';
endcomp;
run;
ods html close;
Cynthia
Hi, I guess I don't understand exactly what you mean when you say: "a listing of zip-code and then the data would be further sum up by state, country & region (all in one report)" -- it's hard to visualize the report you want from this description.
Yes, PROC REPORT can produce summaries on multiple items. So can PROC MEANS, so can PROC TABULATE.
What code have you tried and what is the ultimate destination for the report (RTF, PDF, HTML?)
I have an example of multiple summaries using SASHELP.PRDSALE. Here is what it looks like for 1 country (CANADA), 2 regions (EAST and WEST), 2 divisions (CONSUMER and EDUCATION) and 5 products. This same type of summary also appears for the other 2 countries, GERMANY and U.S.A. -- but for space, I'm only showing one country here. You'd have to run the code below to see the report for all 3 countries in HTML format.
Here's the complete code that produced the report:
ods html path='c:\temp' file='sum_prdsale.html';
title;
proc report data=sashelp.prdsale spanrows;
column country region division product actual predict;
define country / group;
define region / group;
define division / group;
define product / group;
define actual / sum;
define predict / sum;
break after country / summarize style={background=lightyellow};
break after region / summarize style={background=lightgreen};
break after division / summarize style={background=verylightblue};
rbreak after / summarize style=Header;
compute after country;
country = 'C-tot';
line ' ';
endcomp;
compute after region;
region = 'R-tot';
endcomp;
compute after division;
division = 'D-tot';
endcomp;
compute after;
Country = 'Gr-tot';
endcomp;
run;
ods html close;
Cynthia
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.