Announcement

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

  • Automated generation of table1?

    I'm using Phil Clayton's excellent program -table1- to generate a table of baseline characteristics. Is there a way to "feed" the syntax of -table1- from a list of variables in local macro?

  • #2
    I do not quite understand what you want. In the syntax of table1, the variables are given by the vars() option containing a list of arguments of the form
    Code:
        var_spec = varname vartype [varformat] [ \ varname vartype [varformat] \ ...]
    
        Supported variable types:
            contn - continuous, normally distributed
            conts - continuous, skew
            cat   - categorical, groups compared using Pearson's chi-squared
            cate  - categorical, groups compared using Fisher's exact test
            bin   - binary, groups compared using Pearson's chi-squared
            bine  - binary, groups compared using Fisher's exact test
    Do you seek something that will automatically determine the appropriate variable type for each variable specified in your local macro?

    Comment


    • #3
      No really, William. I have a long list of variables, let's say they are all binary. I don't want to manually list and specify each one of them in my code with -table1-.

      Comment


      • #4
        Perhaps this example points you in a helpful direction.
        Code:
        . local vars x1 x2 x3
        
        . local spec
        
        . local sep
        
        . foreach v of varlist `vars' {
          2.         local spec `spec' `sep' `v' bin
          3.         local sep \
          4. }
        
        . display "`spec'"
        x1 bin \ x2 bin \ x3 bin
        
        . display`"your command:  table1, vars( `spec' ) "'
        your command:  table1, vars( x1 bin \ x2 bin \ x3 bin ) 
        
        .

        Comment


        • #5
          Thank you, William! It does work as needed.

          Comment


          • #6
            asdocx has a comprehensive template for creating table1. The template can summarize different types of variables such as continuous and binary / categorical variables in a single table. Table1 template allows different statistics with categorical / factor variables, continuous variables, and binary variables. The allowed statistics are given below:
            Code:
            mean       Mean of the variable
            sd         Standard deviation of the variables
            ci         95% Confidence interval
            n          Counts
            percentage Count as Percentage of total
            %          Count as percentage of total
            The statistics presented in the above table can be selectively used with categorical, binary, and continuous variables. The default statistics for each type of variables are given below: (1) Binary variables : Count (Percentages) (2) Categorical variables : Count (Percentages) (3) Continuous variables : Mean (95% confidence interval)
            Table1 template also support survey weights. I have posted several examples on this page
            Regards
            --------------------------------------------------
            Attaullah Shah, PhD.
            Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
            FinTechProfessor.com
            https://asdocx.com
            Check out my asdoc program, which sends outputs to MS Word.
            For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

            Comment

            Working...
            X