Hello
I create a summary table via Proc Tabulate.
For region and division class variables ,I want to have nested rows instead of placing them next to each other.
However ,in the result I get a table where the region and division class variables are next to each other.
Data Rawtbl;
input ID 1-2 Region$ 4-12 Division$ 13-29 Type 31 expenditures 33-37;
cards;
1 Northeast New England 1 10
2 Northeast Middle Attlantic 1 20
3 Northeast Middle Attlantic 2 30
4 Northeast Middle Attlantic 2 40
5 Northeast New England 2 50
6 West Mountain 1 50
7 West Mountain 1 60
8 West Mountain 2 70
9 West Pacific 2 80
10 West Pacific 1 90
11 West Pacific 2 100
;
Run;
options nodate pageno=1 linesize=80 pagesize=60;
proc tabulate data=Rawtbl format=dollar12. noseps;
class region division type;
var expenditures;
table region*division,
type='Customer Type'*expenditures=' '*sum=' '/ rts=25 indent=4;
format type usetype.;
title 'Energy Expenditures for Each Region';
title2 '(millions of dollars)';
run;
The INDENT argument works fine with LISTING output...
...just not with HTML output
...as mentioned here.
BR
Luhan
Switch it into PROC REPORT .
Data Rawtbl;
input ID 1-2 Region$ 4-12 Division$ 13-29 Type 31 expenditures 33-37;
cards;
1 Northeast New England 1 10
2 Northeast Middle Attlantic 1 20
3 Northeast Middle Attlantic 2 30
4 Northeast Middle Attlantic 2 40
5 Northeast New England 2 50
6 West Mountain 1 50
7 West Mountain 1 60
8 West Mountain 2 70
9 West Pacific 2 80
10 West Pacific 1 90
11 West Pacific 2 100
;
Run;
options nodate pageno=1 linesize=80 pagesize=60;
proc report data=Rawtbl nowd;
columns region division type,expenditures;
define region/group noprint;
define division/group ' ';
define type/across format= usetype.;
define expenditures/analysis sum format=dollar32. ' ';
compute before region;
line @1 region $40.;
endcomp;
title 'Energy Expenditures for Each Region';
title2 '(millions of dollars)';
run;
Data Rawtbl;
input ID 1-2 Region$ 4-12 Division$ 13-29 Type 31 expenditures 33-37;
cards;
1 Northeast New England 1 10
2 Northeast Middle Attlantic 1 20
3 Northeast Middle Attlantic 2 30
4 Northeast Middle Attlantic 2 40
5 Northeast New England 2 50
6 West Mountain 1 50
7 West Mountain 1 60
8 West Mountain 2 70
9 West Pacific 2 80
10 West Pacific 1 90
11 West Pacific 2 100
;
Run;
options nodate pageno=1 linesize=80 pagesize=60;
proc report data=Rawtbl nowd;
columns region division type,expenditures;
define region/group noprint;
define division/group ' ' style={pretext=' ' asis=on};
define type/across format= usetype.;
define expenditures/analysis sum format=dollar32. ' ';
compute before region;
line @1 region $40.;
endcomp;
title 'Energy Expenditures for Each Region';
title2 '(millions of dollars)';
run;
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 25. 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.