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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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: