I've built a dataset containing row percent and count values from a two-way frequency table + the chi-squared p-value and total sample size.
Can I regroup the row percent and count columns under one of the variables as a subheader?
For example:
proc freq data=sashelp.cars;
tables origin*cylinders / chisq totpct outpct list out=freqpct(keep=cylinders origin count pct_row);
output out=chisq(keep=N P_PCHI) all;
run;
data freqpct;
set freqpct;
var=1;
run;
data chisq;
set chisq;
var=1;
run;
proc sql;
create table chisq_freqpct
as select *
from freqpct a
inner join
chisq b
on a.var=b.var;
quit;
proc report data=chisq_freqpct;
column origin cylinders count pct_row N P_PCHI;
define origin / group;
define cylinders / group;
define count / display;
define pct_row / display;
define N / group;
define P_PCHI / group;
run;
Is there a way to use the ASSESS option to display separate columns of pct_row and count values by each value of origin ("Asia", "Europe", "USA"), but still retain N and P_PCHI in the single top row of the table?
Almost there - if I run the following proc report the header and subheaders are correct, but I'm seeing duplicate cylinder rows in the table:
proc report data=chisq_freqpct;
column cylinders origin,(count pct_row) N P_PCHI;
define cylinders / display /*group*/;
define origin / across;
define count / display;
define pct_row / display;
define N / group;
define P_PCHI / group;
run;
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.
Ready to level-up your skills? Choose your own adventure.