BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Joachim133
Fluorite | Level 6

Hello.

 

I need to calculate Wilcoxon Mann-Whitney Odds with 95% CI (WMWodds). I have found a website describing have to do these calculations, but the attached macro is no longer available (see https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/209-31.pdf). Does anyone know, if WMWodds is built into SAS, or where i can download a macro?

 

I'm using SAS 9.4.

 

Best regards

Joachim

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

I searched and found this. Does this help?

%macro WMWodds (_DATASET, _GROUP, _Y);
  ods listing close;

  proc npar1way data = &_dataset. Correct = no;
    class &_GROUP.;
    Var &_Y .;
    ods output WilcoxonScores = WS (keep = Class SumOfScores);
  run;

  proc transpose data = ws out = flag prefix = wscore_;
    var SumOfScores;
    id CLASS;
  run;

  data _NULL_;
    set FLAG;

    if (WSCORE_1> = WSCORE_2) then
      call symput ("_flag", 1);
    else call symput ("_flag",  2);
  run;

  proc logistic data = &_dataset .;
    class &_GROUP.;
    Model &_GROUP. = &_Y .;
    roc;
    ods output ROCAssociation = AUROC;
  run;

  ods listing;

  data WMWODDS;
    set AUROC;

    if (&_FLAG = 1) then
      do WMWOdds = Area / (1-Area);
        SE = StdErr / (1-Area) ** 2;
        LnWMW = log (area / (1-area));
        LnSE = StdErr / (Area * (1-Area))
      end;
    else
      do;
        WMWOdds = (1-Area) / Area;
        SE = StdErr / Area ** 2;
        LnWMW = log ((1-area) / area);
        LnSE = StdErr / (Area * (1-Area)) );
      end;

    z = quantile ("normal", 0.975);
    LowerCI = WMWOdds --z * se;
    UpperCI = WMWOdds + z * se;
    LowerCI_exp = exp (LnWMW --z * lnse);
    UpperCI_exp = exp (LnWMW + z * lnse) if _n_ = 1;
    keep Area StdErr WMWOdds SE LowerCI UpperCI LowerCI_exp UpperCI_exp;
  run;

  title "&_DATASET.";

  proc print noobs;
  run;

%mend;

 

View solution in original post

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

I searched and found this. Does this help?

%macro WMWodds (_DATASET, _GROUP, _Y);
  ods listing close;

  proc npar1way data = &_dataset. Correct = no;
    class &_GROUP.;
    Var &_Y .;
    ods output WilcoxonScores = WS (keep = Class SumOfScores);
  run;

  proc transpose data = ws out = flag prefix = wscore_;
    var SumOfScores;
    id CLASS;
  run;

  data _NULL_;
    set FLAG;

    if (WSCORE_1> = WSCORE_2) then
      call symput ("_flag", 1);
    else call symput ("_flag",  2);
  run;

  proc logistic data = &_dataset .;
    class &_GROUP.;
    Model &_GROUP. = &_Y .;
    roc;
    ods output ROCAssociation = AUROC;
  run;

  ods listing;

  data WMWODDS;
    set AUROC;

    if (&_FLAG = 1) then
      do WMWOdds = Area / (1-Area);
        SE = StdErr / (1-Area) ** 2;
        LnWMW = log (area / (1-area));
        LnSE = StdErr / (Area * (1-Area))
      end;
    else
      do;
        WMWOdds = (1-Area) / Area;
        SE = StdErr / Area ** 2;
        LnWMW = log ((1-area) / area);
        LnSE = StdErr / (Area * (1-Area)) );
      end;

    z = quantile ("normal", 0.975);
    LowerCI = WMWOdds --z * se;
    UpperCI = WMWOdds + z * se;
    LowerCI_exp = exp (LnWMW --z * lnse);
    UpperCI_exp = exp (LnWMW + z * lnse) if _n_ = 1;
    keep Area StdErr WMWOdds SE LowerCI UpperCI LowerCI_exp UpperCI_exp;
  run;

  title "&_DATASET.";

  proc print noobs;
  run;

%mend;

 

Joachim133
Fluorite | Level 6

Sorry for the late reply!
Yes for now it seems to work.

Thanks!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1520 views
  • 1 like
  • 2 in conversation