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
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: