BookmarkSubscribeRSS Feed
Woop122
Calcite | Level 5

Hi,

 

I want to calculate odds ratios, confidence intervals, and overall p-value given this data set and not sure how to do it in SAS. 

      

DATA RACE_TEST;
INPUT RACE $ CMV_STATUS $ COUNT;
DATALINES;
Black CMV 10
Black NO CMV 16
White CMV 41
White NO_CMV 33
Asian CMV 20
Asian NO_CMV 5
Other CMV 16
Other NO_CMV 23

;

 

I would like the output to have an odds ratio (95% CI) for each race category, using white as the reference & 1 overall P-value to see if the race has no effect on CMV status. Is there a way to do all this in 1 statement?

 

Thank you!

 

2 REPLIES 2
art297
Opal | Level 21

Yes, if you can be lenient on how you define one line.

 

DATA RACE_TEST;
  INPUT RACE $ CMV_STATUS $ COUNT;
  DATALINES;
Black CMV 10
Black NO_CMV 16
White CMV 41
White NO_CMV 33
Asian CMV 20
Asian NO_CMV 5
Other CMV 16
Other NO_CMV 23
;
%macro doit (race);
  %let i=1;
  %do %while (%scan(&race,&i.) ne);
  
    proc freq data=RACE_TEST (where=(race in ("%scan(&race,&i.)",'White'))) order=data;
      weight count;
      tables RACE*CMV_STATUS/ chisq cmh;
    run;
    %let i=%eval(&i+1);
  %end;
%mend doit;

%doit(Black Asian Other)

Art, CEO, AnalystFinder.com

 

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

Another approach, using GENMOD, that produces the same results as the solution offered by @art297 (thanks to Art for correcting the dataset):

 

DATA RACE_TEST;
  INPUT RACE $ CMV_STATUS $ COUNT;
  DATALINES;
Black CMV 10
Black NO_CMV 16
White CMV 41
White NO_CMV 33
Asian CMV 20
Asian NO_CMV 5
Other CMV 16
Other NO_CMV 23
;

proc freq data=race_test;
    table race*cmv_status / chisq;
    weight count;
    run;

proc genmod data=race_test;
    class race cmv_status;
    model cmv_status = race / dist=bin type3;
    freq count;
    lsmeans race / ilink cl oddsratio;
    run;

 

The FREQ procedure is not critical to the process, but it does provide some nice estimates, easy test of interaction of race and cmv_status (i.e., whether race and cmv_status are independent; here, they are not), and an overall test of race, all of which you can either find or extract from GENMOD. FREQ of course is limited to categorical variables, whereas GENMOD can also do continuous predictors.

 

Still not one line 🙂 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1644 views
  • 3 likes
  • 3 in conversation