BookmarkSubscribeRSS Feed
sebai
Obsidian | Level 7

I want to create a crosstabulation table between Region and season:

 

 

Spring

Summer

p-value

Region 1

.. %

 ..%

P1

Region 2

.. %

.. %

P2

Region 3

 ..%

.. %

P3

 

I want to:

Check if the % of people in region 1 is different between spring and summer (p-value or OR)

Check if the % of people in region 2 is different between spring and summer (p-value or OR)

Check if the % of people in region 3 is different between spring and summer (p-value or OR)

What test should I use to get the 3 p-values needed?

2 REPLIES 2
PaigeMiller
Diamond | Level 26

As far as I remember, a simple comparison of proportions as you describe (which is not really a 2x2 contingency table at all) is not programmed into any SAS PROC. However, it is simple enough to program in data step.

 

As is usual, @Rick_SAS has written up the explanation at https://blogs.sas.com/content/iml/2017/07/05/test-equality-two-proportions-sas.html

--
Paige Miller
Reeza
Super User

It's not a 2X2 table, since it's literally a 1 (row=REGION) X 2 (column=SEASON) comparison. 

 

One way would be to use a BY statement in the PROC FREQ. 

 

Here's an example that gets the binomial test, which tests that the proportions should be 50% in each group. Note that you'll need the N's here, NOT the percentages. You need both the N and percentages or the raw data.

 

proc sort data=sashelp.class out=class; by age sex; run;

ods output binomialTest=pvalues;
proc freq data=class;
by age;
table sex / out=summary_table chisq binomial;
run;

PS. The reusults are not in a nice neat table, but all the information is in the two output tables:

  1. Summary_Table -> has the counts and percentages
  2. Values -> has the p-values for each test

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2 replies
  • 922 views
  • 5 likes
  • 3 in conversation