Announcement

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

  • Tabout: Twoway table of means and sd

    Hi!

    I'm trying to make a table in Excel (via text-file) with tabout for this syntax:
    by dichotom: tabstat var1 var2 var3, c(s) s(n mean sd)
    where [dichotom] is the variable in the column and [var1-3] is in the rows. Var1-3 are continuous variables

    Something like this
    Yes Yes Yes No No No Total
    n mean sd n mean sd n
    Var1
    Var2
    ...

    I've tried:
    svy: tabout var1 var2 var3 dichotom using tab1.txt, sum s(n mean sd)
    which is all wrong and not allowed, as I know, but may give a clue on where I'm heading to. (I have not svyset my dataset, don't understand if it's right, and which set)

  • #2
    You can try this form of code: tabout dichotom using auto.txt, cells(N var1 N var2 N var3 mean var1 mean var2 mean var3 sd var1 sd var2 sd var3) sum replace

    For example:
    Code:
    sysuse auto
    tabout foreign using auto.txt, cells(N price N mpg N weight mean price mean mpg mean weight sd price sd mpg sd weight) sum replace

    Comment


    • #3
      Hi Chen!

      Thanks a lot! It works, but it means a lot of typing as I have 16 VAR x 3 statistics per VAR. And with this syntax, the row/columns are opposite of what I need.

      Comment


      • #4
        Hi Christian! Please refer to "tabout user guide" http://www.ianwatson.com.au/pubs/tabout_user_guide.pdf in page 35 for oneway summary tables:
        the syntax for the contents option: where each summary measure is followed by a variable name: c(mean mpg mean weight mean length...);

        Comment


        • #5
          Thanks a lot for link to v3 of the manual, Chen! This will help.

          I have tried this before,
          tabout var1 var2 var3 using file.txt, replace c(mean sd)
          but get:
          Invalid type of entry in cells option, or you may have forgotten to turn on the sum or svy option
          (see my first post).

          Why is that/how can I turn on sum and/or svy?
          Last edited by Christian Myrstad; 29 Oct 2021, 00:25.

          Comment


          • #6
            include sum and/or svy in options to turn them on,
            Code:
            tabout var1 var2 var3 using file.txt, replace c(mean sd) sum svy

            Comment


            • #7
              Hi Christian Myrstad, to attain outcome that you reported in 1#, I recommend another user-written command -desctable-, which was written by Trenton Mize & @Bianca Manago. This is the command's homepage https://www.trentonmize.com/software/desctable. You can install this command by net install.

              Code:
              net install desctable, from("https://tdmize.github.io/data/desctable")
              After installing, you can try the following code:

              Code:
              sysuse auto
              desctable price mpg weight, group(foreign) stat(n mean sd) filename(christian)
              Last edited by Chen Samulsion; 29 Oct 2021, 07:23.

              Comment

              Working...
              X