BookmarkSubscribeRSS Feed
RobertWF1
Quartz | Level 8

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?

1 REPLY 1
RobertWF1
Quartz | Level 8

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 713 views
  • 0 likes
  • 1 in conversation