BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dhana18
Obsidian | Level 7
data MSM2017;
input Alerts $   MSM $  Counts;
Datalines;
No Yes 20
No No 240
Yes Yes 3
Yes No 3
 ;
proc freq data=MSM2017;
tables MSM*Alerts/RELRISK;
WEIGHT COUNTS ;
RUN;

Hi i would like to know what is wrong with the code i have above.  There are 3 patients that are MSM and they are Alert, and there are 20 patients that are MSM but they are not alert. There are 3 patients that are Alerts but they are not MSM, and there are 240 patients that are not MSM and Not Alert.

I would like to know what is risk of being MSM to become an Alert.  Is MSM at higher risk of becoming an alert patient?

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @Dhana18,


@Dhana18 wrote:
My colleague got RR of 10.57 using excel

That value is correct and you'll obtain it also with SAS (for "Column 2," i.e., Alerts='Yes') if you switch the rows of the 2x2 table, i.e., have MSM='Yes' as the first row, so that the relative risk is the risk ratio of MSM='Yes' vs. MSM='No' and not vice versa (which is what you currently get: 0.09465... = 1/10.5652...). One way to achieve this is to sort the dataset as needed and then use the ORDER=DATA option of the PROC FREQ statement.

proc sort data=MSM2017;
by descending MSM descending Alerts;
run;

proc freq data=MSM2017 order=data;
tables MSM*Alerts/RELRISK;
WEIGHT COUNTS ;
RUN;

Note however, how wide the 95% confidence interval for this relative risk is (due to the small numbers in column 2, as Reeza mentioned).

 

Edit: If you also want to report the odds ratio, you should switch the columns as well (see extended BY statement above; the relative risk is then reported as that of "Column 1"). Thanks to @Reeza for pointing this out.

View solution in original post

6 REPLIES 6
Reeza
Super User
What makes you think something is wrong with your code? You have a small event size, so I question the reliability of this analysis but from a purely SAS technical standpoint there's no issue with the code you've shown. It runs without errors for me.
Dhana18
Obsidian | Level 7
I may be not interpreting it well. So what is the risk ratio? My colleague got RR of 10.57 using excel
Reeza
Super User
So your real question is how to interpret the results from this code?
FreelanceReinh
Jade | Level 19

Hi @Dhana18,


@Dhana18 wrote:
My colleague got RR of 10.57 using excel

That value is correct and you'll obtain it also with SAS (for "Column 2," i.e., Alerts='Yes') if you switch the rows of the 2x2 table, i.e., have MSM='Yes' as the first row, so that the relative risk is the risk ratio of MSM='Yes' vs. MSM='No' and not vice versa (which is what you currently get: 0.09465... = 1/10.5652...). One way to achieve this is to sort the dataset as needed and then use the ORDER=DATA option of the PROC FREQ statement.

proc sort data=MSM2017;
by descending MSM descending Alerts;
run;

proc freq data=MSM2017 order=data;
tables MSM*Alerts/RELRISK;
WEIGHT COUNTS ;
RUN;

Note however, how wide the 95% confidence interval for this relative risk is (due to the small numbers in column 2, as Reeza mentioned).

 

Edit: If you also want to report the odds ratio, you should switch the columns as well (see extended BY statement above; the relative risk is then reported as that of "Column 1"). Thanks to @Reeza for pointing this out.

Reeza
Super User
I don’t believe the Alert column is in the right order though?
FreelanceReinh
Jade | Level 19

Thanks, @Reeza, this is a good point if @Dhana18 plans to report the odds ratio in addition to the relative risk. (The relative risks are computed for both columns, but the odds ratio depends on the order of columns.) I'm going to edit my suggested solution.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 1829 views
  • 3 likes
  • 3 in conversation