Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exporting output of ManWitney U Test

    Hi,
    I am unable to find a way to export output of ManWitney U (ranksum) Test for independent samples.

    Here is how data looks (sample for few observations):
    cat tot_dis
    Batch 18
    Batch 1
    Stream 12.5
    Stream 5.5
    Stream 15
    Batch 19
    Batch 6.5
    Batch 10
    Stream 0
    Stream 3.5
    Batch 3

    I am running this code:
    ranksum tot_dis, by(cat)
    scalar define U1=r(sum_obs)-r(N_1)*(r(N_1)+1)/2
    scalar define U2=r(N_1)*r(N_2)-U1
    display in smcl as text "Mann-WhitneyU="as result min(U1,U2)



    This is the output:

    Two-sample Wilcoxon rank-sum (Mann-Whitney) test

    cat | obs rank sum expected
    -------------+---------------------------------
    Batch | 172 23438 22704
    Stream | 91 11278 12012
    -------------+---------------------------------
    combined | 263 34716 34716

    unadjusted variance 344344.00
    adjustment for ties -588.32
    ----------
    adjusted variance 343755.68

    Ho: tot_dis(cat==Batch) = tot_dis(cat==Stream)
    z = 1.252
    Prob > |z| = 0.2106

    . scalar define U1=r(sum_obs)-r(N_1)*(r(N_1)+1)/2

    . scalar define U2=r(N_1)*r(N_2)-U1

    . display in smcl as text "Mann-WhitneyU="as result min(U1,U2)
    Mann-WhitneyU=7092

    .
    end of do-file

    This is what I need help on:

    How can I export value of U and p value? I have to do this for many variables and copy pasting is time consuming.


    Thanks in anticipation.
    Puran

  • #2
    So, you might try logout (SSC) or frmttable (STJ, so use findit frmttable; it's sg97_5). You might also be able to do it with asdoc or tabout (both on SSC).

    Code:
    ssc install logout
    logout, save(testing_logout) excel replace: ranksum tot_dis, by(cat)
    The above gets it into Excel, but I don't know how to append tables to the same Excel file (like outreg2 would). Also, I don't know how to change the format of it.


    The 2nd way would be to use frmttable (this is probably the way I would go).

    Comment

    Working...
    X