Announcement

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

  • How to use putdocx table?

    Hi I'm having trouble with a putdocx command

    I would like to put on word a table like that :

    macros:
    r(name3) : "GS >=3+4"
    r(name2) : "GS<=3+3"
    r(name1) : "no biopsy"

    matrices:
    r(Stat3) : 8 x 6
    r(Stat2) : 8 x 6
    r(Stat1) : 8 x 6
    r(StatTotal) : 8 x 6

    Using
    . tabstat psa trusprosvol fk_score ex_score likelihood_hg, by(GGtot_neg_gg1) statistics (count mean sd min p25 p50 p75 max) columns(statistics) save

    I'm using the following codes:

    "putdocx clear
    putdocx begin

    tabstat psa trusprosvol fk_score ex_score likelihood_hg, by(GGtot_neg_gg1) statistics (count mean sd min p25 p50 p75 max) columns(statistics) save

    return list
    matrix LabResults1 = r(StatTotal)'

    matrix LabResults2 = r(stat3)
    matrix LabResults3 = r(stat2)
    matrix LabResults4 = r(stat1)


    putdocx table Table1 = matrix(LabResults1) , rownames colnames
    putdocx table Table2 = matrix (LabResults2)
    putdocx table Table3 = matrix (LabResults3)
    putdocx table Table4 = matrix (LabResults4)

    putdocx save "table_stat1.docx", replace"


    But I do not have only the fist table and then 3 empty cells.

    Can you help me , please



  • #2
    The difference between
    Code:
    putdocx table Table1 = matrix(LabResults1) , rownames colnames
    which produces output, and
    Code:
    putdocx table Table2 = matrix (LabResults2) 
    putdocx table Table3 = matrix (LabResults3) 
    putdocx table Table4 = matrix (LabResults4)
    which do not, is that the latter three putdocx commands have a space between matrix and the left parenthesis following it.

    Try it without the space and see if that helps.
    Code:
    putdocx table Table1 = matrix(LabResults1) , rownames colnames
    putdocx table Table2 = matrix(LabResults2) 
    putdocx table Table3 = matrix(LabResults3) 
    putdocx table Table4 = matrix(LabResults4)

    Comment


    • #3
      Hi thanks for your answer:
      unfortunately is still not working!

      I tried many many solution but still I have the first table and then 3 empty.

      Here my codes:


      putdocx clear
      putdocx begin, pagesize(letter) font(Arial,12,black)

      tabstat psa trusprosvol fk_score ex_score likelihood_hg, by(GGtot_neg_gg1) statistics (count mean sd min p25 p50 p75 max) columns(statistics) save

      return list

      matrix LabResults1 = r(StatTotal)'
      matrix LabResults2 = r(stat3)'
      matrix LabResults3 = r(stat2)'
      matrix LabResults4 = r(stat1)'

      putdocx table Table1 = matrix(LabResults1) , rownames colnames
      putdocx table Table2 = matrix(LabResults3)
      putdocx table Table3 = matrix(LabResults2)
      putdocx table Table4 = matrix(LabResults1)

      putdocx save "table_stat4.docx", replace

      Thanks

      Comment


      • #4
        Note that in post #1 we see
        Code:
        matrices:
        r(Stat3) : 8 x 6
        r(Stat2) : 8 x 6
        r(Stat1) : 8 x 6
        r(StatTotal) : 8 x 6
        Capitalization matters!
        Code:
        matrix LabResults2 = r(stat3)'
        matrix LabResults3 = r(stat2)'
        matrix LabResults4 = r(stat1)'
        should be
        Code:
        matrix LabResults2 = r(Stat3)'
        matrix LabResults3 = r(Stat2)'
        matrix LabResults4 = r(Stat1)'

        Comment


        • #5
          OMG, really thanks!!!

          I tried so many times and I spent a lot of time in it.

          Thanks for your help.

          Comment

          Working...
          X