Hi:
You could do this kind of report (with nested counts) using either PROC REPORT or PROC TABULATE. It really depends on how you want the final look and feel of the report. You do not need to build arrays or views. PROC TABULATE is the greatest slicer and dicer of data invented and PROC REPORT runs a close second in the cross-tab department.
The only thing is that It will be hard to "label" the headers on the left, as you show (for Rel Att and Birth Control), but user-defined formats will make the meaning of each 1 and 2 clear. And PROC TABULATE comes closest to allowing you to label on the left, since you can put text strings into the TABULATE box area.
I used SASHELP.PRDSALE to fake up some data -- and picked some values for the user-defined formats. If you compare the results of the programs below, you can then decide whether to spend your efforts learning PROC REPORT or PROC TABULATE.
cynthia
[pre]
data demog;
set sashelp.prdsale;
if country = 'GERMANY' and region = 'EAST' then POLVIEW = 1;
else if country = 'GERMANY' and region = 'WEST' then POLVIEW = 2;
else if country = 'CANADA' and prodtype = 'FURNITURE' then POLVIEW = 2;
else if country = 'CANADA' and prodtype = 'OFFICE' then POLVIEW = 1;
else POLVIEW = 3;
if region = 'EAST' then premarital_sex = 1;
else premarital_sex = 2;
if division = 'CONSUMER' then rel_att = 1;
else rel_att = 2;
if product in ('BED', 'DESK') then birth_cont = 1;
else birth_cont = 2;
label polview = 'Political Views'
rel_att = 'Rel. Att.'
birth_cont = 'Birth Cont.'
premarital_sex = 'PreMarital Sex';
run;
ods listing close;
proc format;
value pv 1='Sort of Political'
2='Not Political'
3='Very Political';
value ra 1 = 'Not Religious'
2 = 'Very Religious';
value ps 1 = 'Believe Premarital Sex'
2 = 'Not Believe Premarital Sex';
value bc 1 = 'Use Birth Control'
2 = 'Do Not Use Birth Control';
run;
ods html file='c:\temp\nested_tab.html' style=sasweb;
proc tabulate data=demog f=comma8.;
title 'TAB 1) Unformatted Values for 1 and 2';
class polview premarital_sex rel_att birth_cont;
table polview all='Total',
n=' '*(premarital_sex*rel_att*birth_cont all='Total')
/ box = 'Nested Counts';
keyword all / style={vjust=b};
run;
ods escapechar='~';
proc tabulate data=demog f=comma8.;
title 'TAB 2) Formatted Values for 1 and 2';
class polview premarital_sex rel_att birth_cont;
table polview all='Total',
n=' '*(premarital_sex=' '*rel_att=' '*birth_cont=' ' all='Total')
/ box = '~{newline 1}Rel. Att. ~{newline 2} Birth Control ' ;
format polview pv. premarital_sex ps. rel_att ra. birth_cont bc.;
keyword all / style={vjust=b};
run;
ods _all_ close;
ods html file='c:\temp\nested_report_counts.html' style=sasweb;
proc report data=demog nowd;
title 'REP 1) PROC REPORT with Nested Counts';
column polview premarital_sex, rel_att, birth_cont n;
define polview / group
style(column)=Header;
define premarital_sex / across;
define rel_att / across;
define birth_cont / across;
define n / 'Total';
rbreak after / summarize;
run;
proc report data=demog nowd split='#';
title 'REP 2) PROC REPORT with Formats Applied';
column polview premarital_sex, rel_att, birth_cont n;
define polview / group f=pv. order=data
style(column)=Header{just=l};
define premarital_sex / across f=ps. order=data;
define rel_att / across ' ' f=ra. order=data;
define birth_cont / across ' ' f=bc. order=data;
define n / 'Total';
rbreak after / summarize;
compute polview;
if _break_ = '_RBREAK_' then do;
call define(_COL_, 'style', 'style=Header{prehtml="Total"}');
end;
endcomp;
run;
ods _all_ close;
ods listing;
title; footnote;
[/pre]