Announcement

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

  • output svy results to excel

    HI all, I'd like to export the below results (specifically the column for RACETHM_n, proportion, lb and ub) to excel. It seems there are many options such as putexcel, tabout, esttab. Could someone suggest some code I could try to get these into excel?

    Many thanks in advance for any advice.



    Code:
    
    
    .  svy, subpop(DGRDG_n1): tabulate RACETHM_n, ci level(90)
    (running tabulate on estimation sample)
    
    Number of strata   =         1                  Number of obs     =      1,311
                                                    Population size   = 252,142.35
                                                    Subpop. no. obs   =        547
                                                    Subpop. size      = 113,793.95
                                                    Replications      =        320
                                                    Design df         =        319
    
    ----------------------------------------------
    RACETHM_n | proportion          lb          ub
    ----------+-----------------------------------
     AsianNHO |       .078       .0527       .1138
         AIAN |    7.3e-05     1.0e-05     5.1e-04
        Black |      .0423        .018       .0965
     Hispanic |      .0695       .0368       .1274
        White |      .7969       .7237       .8546
           MR |      .0132       .0056       .0306
              | 
        Total |          1                        
    ----------------------------------------------
      Key:  proportion  =  cell proportion
            lb          =  lower 90% confidence bound for cell proportion
            ub          =  upper 90% confidence bound for cell proportion

  • #2
    estout from SSC works really well with -svy- commands.

    Code:
    ssc install estout, replace
    eststo m1: estpost svy, subpop(DGRDG_n1): tabulate RACETHM_n, ci level(90)
    esttab m1 using myfile.csv, replace cells("b lb ub")  collab(proportion lb ub) nonum mlab(none)

    Comment


    • #3
      This worked perfectly. Thank you so much!!

      Comment


      • #4
        Just a followup question. Is there a way to round the output for proportion and the CIs to 3 decimal places?

        Comment


        • #5
          You can use:

          Code:
          esttab m1 using myfile.csv, replace cells("b(fmt(3)) lb(fmt(3)) ub(fmt(3))") collab(proportion lb ub) nonum mlab(none)
          although I'd recommend

          Code:
          esttab m1 using myfile.csv, replace cells("b(fmt(a3)) lb(fmt(a3)) ub(fmt(a3))") collab(proportion lb ub) nonum mlab(none)
          so that you avoid integers like 1 being written as "1.000".

          Comment


          • #6
            Excellent. thanks again!!!

            Comment

            Working...
            X