Announcement

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

  • order of result using collect after table

    Hi all,

    I'm using the collect feature after table to modify the result.
    I have more than 10 commands in my table.
    After using the collect to modify the labels, Stata re-order the rows (1 10 11 12 2 3 4 5 6 7 8 9).

    Is there a possibility to keep the ordering form 1 to 12?

    I'm using stata-17:



    table (command) (result), ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic had_partner x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic had_sex x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic df3mdd_di x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic yf3mdd_di x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic df401_di x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic yf401_di x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic df411_di x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic yf411_di x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic wish_to_die x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic thought_suicid x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic plan_suicid x) ///
    command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic try_suicid x)

    collect label levels command 1 "had partner" ///
    2 "had sex" ///
    3 "df3mdd" ///
    4 "yf3mdd" ///
    5 "df401" ///
    6 "yf401" ///
    7 "df411" ///
    8 "yf411" ///
    9 "wish to die" ///
    10 "thought suicid" ///
    11 "plan suicid" ///
    12 "try suicid" , replace



    -----------------------------------
    odds_ratio pvalue
    -----------------------------------
    had partner 0.799 0.00
    thought suicid 1.128 0.06
    plan suicid 1.054 0.56
    try suicid 0.868 0.29
    had sex 0.769 0.00
    df3mdd 1.006 0.92
    yf3mdd 0.917 0.42
    df401 0.972 0.73
    yf401 1.057 0.53
    df411 1.070 0.52
    yf411 1.203 0.16
    wish to die 1.086 0.17
    -----------------------------------


    Thanks

  • #2
    You should be able to specify the order by doing:
    Code:
    collect layout (command[1 2 3 4 5 6 7 8 9 10 11 12]) (result)

    Comment


    • #3
      As an example of changing up the order, consider:

      Code:
      clear all
      sysuse nlsw88, clear
      
      table (command) (result), ///
      command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic collgrad wage) ///
      command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic smsa wage) ///
      command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic c_city wage) ///
      command( odds_ratio = r(table)[1,1] pvalue = r(table)[4,1]: logistic south wage)
      
      collect label levels command 1 "college graduate" ///
      2 "lives in SMSA" ///
      3 "lives in a central city" ///
      4 "lives in the south", replace
      
      collect layout (command[1 4 2 3]) (result)
      which produces:

      Code:
      . collect preview
      
      ------------------------------------------------
                              |  odds_ratio     pvalue
      ------------------------+-----------------------
      college graduate        |    1.104026   2.39e-26
      lives in the south      |    .9473524   3.34e-09
      lives in SMSA           |    1.114719   4.42e-16
      lives in a central city |    1.016558   .0330634
      ------------------------------------------------

      Comment


      • #4
        Perfect, thank you very much.

        Comment

        Working...
        X