Announcement

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

  • create table from var values

    Hello,

    I am using Stata 17 and would like to create a table showing the var values for each observation which includes a string var.

    The only way I can manage it is to do it with the browser, copy and paste it into a word table. Is there a way to do it with a Stata command?

    Robert

  • #2
    What would the table show?

    Comment


    • #3
      Hello Nick,

      I have 2 vars with 3 observations each. Var1= 1, 2, 3, Var2= 2,3,4

      I would like the table to show:
      Var1 Var2
      1 2
      2 3
      3 4

      I can create this table using the command "br var1 var2", but then I need to copy it and manually paste it into word and reformat it.

      Does Stata 17 with the new tables feature have the ability to create this simple table with export to Word?

      Thanks,

      Robert

      Comment


      • #4
        I don't have Stata 17, but you can do this using putdocx.


        Code:
        
        clear
        input str1(var1 var2)
        "1" "2"
        "2" "3"
        "3" "4"
        end
        
        
        putdocx clear 
        putdocx begin
        
        putdocx paragraph 
        putdocx table tablename = data("`r(varlist)'"),  varnames headerrow(1)  
        putdocx table tablename(.,.)
        
        putdocx save "Example" , replace

        Comment


        • #5
          Thanks much!

          Comment

          Working...
          X