Announcement

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

  • Creating descriptive statistics using table and export results using collect

    I want to create a table of descriptive statistics with five levels of a group variable named district name. The table command is creating five separate table for each district. I want to combine this tables and like to create a table all together with rows as variables and columns as statistics (N mean sd) within the group variable of district for each variables in the row.

    The code I am using as follows but it produces four tables while exporting. I would like to have it in one table.

    Thanks in advance for any solutions!

    Code:
    global bcd var1 var2 var3 var4 var5 ....... var25
    
    
    table (var districtname)()  , ///
                        statistic(mean     $bcd )  ///
                        statistic(sd    $bcd )  ///
                        statistic(n      $bcd )    ///
                        name (transferts) showcounts nototals ///
                        nformat(%9.0f count total) ///
                        nformat(%9.2f mean sd) replace    
                                    
        collect layout (var districtname) (result[count  mean total]) , name(transferts)
        collect label list result
        collect label levels result sd "SD", modify
        collect label levels result count "N", modify
        collect label levels result mean "Mean/Proportion", modify
        collect label levels result total "SD", modify
        collect recode result sd=total
        collect style cell, border(right, pattern(nil) )    
        collect style cell, font (calibri,)
        collect style cell result[mean count total],  halign(center) // change font
        collect style cell result[total], nformat(%9.3gc) // change font    
        collect preview
Working...
X