BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

 

data shoes(keep=region subsidiary stores);    
set sashelp.shoes;          
if region in ('Africa','Middle East','Asia');      
run;            
             
proc report data= shoes;        
column region subsidiary stores ;      
define region / group style (column)=[cellwidth=100pt] "Area";  
define subsidiary / group     style(column)=[cellwidth=100pt];  
define stores / sum "Stores" style(column)=[cellwidth=90pt];  
rbreak after / summarize style (summary)= Header;  
compute after;          
region = 'Grand Total';        
endcomp;          
break after region / ol summarize skip;/*total by group*/  
rbreak after /summarize;        
/*rbreak after / summarize style (summary)= Header;*/  
run;            
        Desired Result  
Area Subsidiary Stores   Area Subsidiary Stores
Africa Addis Ababa 65   Africa Addis Ababa 65
  Algiers 101     Algiers 101
  Cairo 88     Cairo 88
  Johannesburg 51     Johannesburg 51
  Khartoum 71     Khartoum 71
  Kinshasa 56     Kinshasa 56
  Luanda 30     Luanda 30
  Nairobi 70     Nairobi 70
Africa   532   Total for Africa   532
Asia Bangkok 5   Asia Bangkok 5
  Seoul 59     Seoul 59
  Tokyo 1     Tokyo 1
Asia   65   Total for Asia   65
Middle East Al-Khobar 110   Middle East Al-Khobar 110
  Dubai 153     Dubai 153
  Tel Aviv 134     Tel Aviv 134
Middle East   397   Total for Middle East Middle East   397
Grand Total   994   Grand Total   994
        Pct Middle East/Total 39.9396

I want to do the following:

1. Show the name in the subtotal as "Total for the variable"

2. Divide the last variable "Middle East into the Grand total and get the Pct Middle East/Total  or 397/994

1 REPLY 1
PaigeMiller
Diamond | Level 26

Answer to #1: https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-can-you-place-descriptive-text-in-a-BREAK...

 

Answer to #2: I'm sure this can be done in PROC REPORT, but I find it easier to do the calculations in PROC SUMMARY and a DATA step if necessary, and then just use PROC REPORT to display the results.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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