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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 426 views
  • 0 likes
  • 1 in conversation