Announcement

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

  • #16
    This worked for me (I made up a svy weight).

    Code:
    putexcel set putexcel2.xlsx, sheet(example1) replace
    putexcel A1 = "Variable"
    putexcel B1 = "Bachelor_hes?"
    putexcel C1 = "Means"
    
    local row = 2
    foreach var in wasgach wasgeink wasfihan wasmfqe wasfach11 wasfort wasfawe wasmtza wasbeta wasfrei {
        forv i = 0/3 {
             svy, subpop(Bachelor_hes`i'): mean `var'
             local m = el(r(table),1,1)
             putexcel A`row' = "`var'"
             putexcel B`row' = "Bachelor_hes`i'"
             putexcel C`row' = `m'
             local ++row
    }
    }
    Last edited by George Ford; 17 Nov 2022, 15:04.

    Comment


    • #17
      This is probability weights (in particular, pw=k_gewicht in my case).
      Thanks.

      Comment


      • #18
        Dear George Ford:

        I retried now and everything is ok:

        Code:
        putexcel set putexcel2.xlsx, sheet(example1) replace
        putexcel A1 = "Variable"
        putexcel B1 = "Bachelor_hes?"
        putexcel C1 = "Means"
        local row = 2
        foreach var in wasgach wasgeink wasfihan wasmfqe wasfach11 wasfort wasfawe wasmtza wasbeta wasfrei {
        forv i = 0/3 {
        svy, subpop(Bachelor_hes`i'): mean `var'
        local m = el(r(table),1,1)
        putexcel A`row' = "`var'"
        putexcel B`row' = "Bachelor_hes`i'"
        putexcel C`row' = `m'
        local ++row } }

        Thank you so much for your help and patience.

        --
        Michael

        P.S: George Ford: Just by curiosity, why do we have to put local m = el(r(table),1,1) after svy,subpopo(`c'`i'):mean `var'?
        Thanks in advance.
        Last edited by Michael Duarte Goncalves; 18 Nov 2022, 00:51.

        Comment


        • #19
          Hello, I would like to export my all data shown below on Excel with putexcel:

          Code:
          Number of strata =      1         Number of obs   =     12,135
          Number of PSUs   = 12,135         Population size = 20,798.814
                                            Subpop. no. obs =      4,043
                                            Subpop. size    =  6,826.539
                                            Design df       =     12,134
          
          
          --------------------------------------------------------------
                       |             Linearized            Logit
                       | Proportion   std. err.     [95% conf. interval]
          -------------+------------------------------------------------
             k_uebverl |
                    0  |   .6167363   .0077506      .6014343    .6318104
                    1  |   .1194908   .0050217      .1099926    .1296898
                    2  |   .0940348   .0044806       .085612    .1031927
                    3  |    .020252   .0021745      .0164013    .0249838
                    4  |   .0111293      .0017      .0082458    .0150059
                    5  |   .0099072    .001611      .0071999    .0136185
                    6  |   .0143541   .0019683      .0109656    .0187697
                    7  |   .0235214   .0024309      .0191992     .028788
                    8  |   .0070225   .0013086      .0048717    .0101133
                    9  |   .0067312   .0013486       .004543    .0099628
                   10  |   .0066279   .0014243      .0043473     .010093
                   11  |    .008272   .0016324      .0056154      .01217
                   12  |   .0119176   .0019282       .008674    .0163541
                   13  |   .0242573   .0024679      .0198625    .0295952
                   14  |   .0115534   .0016617      .0087114    .0153083
                   15  |   .0037225   .0009338      .0022758    .0060835
                   16  |   .0017873   .0006813      .0008463    .0037706
                   17  |    .000448   .0003167       .000112    .0017899
                   18  |   .0028701   .0008847      .0015678    .0052485
                   19  |   .0048346   .0011266      .0030605    .0076293
                   20  |   .0005298   .0003805      .0001296    .0021632
                   21  |          0  (no observations)
          --------------------------------------------------------------

          Comment


          • #20
            I have tried to create the following loop which gives me the r(198) error:
            Code:
            putexcel set Partie1_MandatDG2022_mdg.xlsx, sheet(Figure 11) modify
            putexcel A2 = "Variables"
            putexcel B2 = "Variables Names" 
            putexcel C2 = "Bachelor"
            putexcel D2 = "Variable Labels"
            putexcel E2 = "Means"
            putexcel F2 = "Proportions x 100 "
            putexcel G2 = "N"
            local row = 3
            *
            *
            forvalues i = 0/3 {
            local ba_hes Bachelor_hes
            foreach c of local ba_hes {
            svy,subpop(`c'`i'): prop k_uebverl
            local m = el(e(b)) // help matrix functions - "el(s,i,j)"
            *You'll need to pull it out of r(table)
            local n = e(N_subpop)
            describe Bachelor_hes`i'
            local varlabel : var label Bachelor_hes`i'
            local varlabel2 : var label `var'
            putexcel A`row' = "`var'"
            putexcel B`row' = "`varlabel2'"
            putexcel C`row' = "Bachelor_hes`i'"
            putexcel D`row' = ("`varlabel'")
            putexcel E`row' = `m'
            putexcel F`row' = (`m'/5*100)
            putexcel G`row' = `n'
            local ++row
            }
            }
            *
            *
            forvalues i=0/2{
            local ba_heu Bachelor_heu
            foreach c of local ba_heu {
            svy,subpop(`c'`i'): prop k_uebverl
            local m = el(e(b))
            local n = e(N_subpop)
            describe Bachelor_heu`i'
            local varlabel : var label Bachelor_heu`i'
            local varlabel2 : var label `var'
            putexcel A`row' = "`var'"
            putexcel B`row' = "`varlabel2'"
            putexcel C`row' = "Bachelor_heu`i'"
            putexcel D`row' = ("`varlabel'")
            putexcel E`row' = `m'
            putexcel F`row' = (`m'/5*100)
            putexcel G`row' = `n'
            local ++row
            }
            }
            Does anyone have a suggestion for me, please?

            Many thanks in advance.
            Last edited by Michael Duarte Goncalves; 21 Nov 2022, 05:53.

            Comment


            • #21
              So I try to get this data for each of the bachelors presented above.
              The problem is surely with my local m = el(e(b)). I would like to extract the whole table presented in point #19 by Bachelor and export them then in Excel format.

              Michael
              Last edited by Michael Duarte Goncalves; 21 Nov 2022, 05:55.

              Comment


              • #22
                the line "m = " pulls the mean off r(table) [type matrix list r(table)]. if you want the whole table, then export the maxtrix r(table), though you may have to -matrix R = r(table)- and use R in the putexcel command.

                Comment


                • #23
                  Thanks George Ford for the clarification!

                  Best,

                  Michael

                  Comment

                  Working...
                  X