BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gnetnaw
Calcite | Level 5

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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.

use_report_summary.png

 

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

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

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.

use_report_summary.png

 

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

gnetnaw
Calcite | Level 5
Yes, this is what i am looking for. Thanks a lot!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 2 replies
  • 6679 views
  • 0 likes
  • 2 in conversation