BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

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;
4 REPLIES 4
Luhan
Obsidian | Level 7

The INDENT argument works fine with LISTING output...

Capture1.PNG

...just not with HTML output

Capture2.PNG

...as mentioned here.

 

BR

Luhan

andreas_lds
Jade | Level 19
If you don't create listing output (hardly anybody does this nowadays) you can skip linesize and pagesize, too.

AFAIK their is no option to get the output as you want it, maybe a custom template can help, but this is just an idea, I haven't used proc template lately and never for such tasks.
Ksharp
Super User

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;

Ksharp
Super User
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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1638 views
  • 2 likes
  • 4 in conversation