BookmarkSubscribeRSS Feed
Tamara3
Calcite | Level 5

Among a population, I want to see if there is a significant relationship between being SMI and receiving MHcare using frequency tables and ChiSqu, and there was.

PROC FREQ; 
table MentalSer*SMI/ chisq or;
RUN;

 

****Now I want to further investigate to see if there is a relationship between income and those who received MHcare among those who said "yes" to SMI. How do I conduct a frequency table, ChiSqu Odd Ratio? Should I use a control statement? If so, how?

 

 

Also, when to us Odd Ratio or Relrisk?

PROC FREQ;
	TABLES SMI * MentalSer / chisq relrisk;
RUN;

 

2 REPLIES 2
ballardw
Super User

One way to get analysis for each level of a variable is to use a BY statement, which would require sorting the data by any variables on the by stateement.

 

PROC FREQ;

   by smi;
   TABLES income* MentalSer / chisq relrisk;
RUN;

Or

PROC FREQ;


   TABLES smi*income* MentalSer / chisq relrisk;
RUN; Which produce a separate table for each smi level.

 

If you are only interested in one specific level you can use

PROC FREQ;

   where smi='Yes'; /* <= the value  has to be actual values of the variable */
   TABLES income* MentalSer / chisq relrisk;
RUN;

 

 

The approach you take would depend on what you are doing over all. Proc Freq can have multiple TABLES statements each with separate options. you could get both analysis  with

 

Proc freq;

   tables MentalSer*SMI/ chisq or;

   tables smi*MentalSer*income/ chisq relrisk;

run;

 

The BY and WHERE would restrict analysis for all records where the separate tables statments would use all records.

 

Tamara3
Calcite | Level 5

Those codes worked. 🙂

 

Thank you for your help. Woman Very Happy 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 779 views
  • 0 likes
  • 2 in conversation