Announcement

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

  • svy command - survey data

    Hello,

    I´m using a survey data (example below) and I´m trying to calculate some statistics using the svy command. However, everytime I used it, appear a message saying "no observations". For example if I use the command svy: tab i_sex it appears a message saying "no observations". Can you help me with this? Thank you in advance.



    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long(pidp pid i_psu) int i_strata byte i_sex float i_indscui_lw
    68041499        -8 2084 2042 2 .
    68044215        -8 2084 2042 1 .
    68046939        -8 2084 2042 1 .
    68056463        -8 2108 2054 2 .
    68060535        -8 2108 2054 1 .
    68063935        -8 2132 2066 1 .
    68142143        -8 2276 2138 1 .
    68180899        -8 2348 2174 2 .
    68191775        -8 2372 2186 1 .
    68197223        -8 2396 2198 1 .
    68226455        -8 2444 2222 2 .
    68228503        -8 2444 2222 1 .
    68230539        -8 2444 2222 1 .
    68244819        -8 2468 2234 1 .
    68247539        -8 2492 2246 1 .
    68265219        -8 2516 2258 2 .
    68288335        -8 2564 2282 1 .
    68293103        -8 2564 2282 2 .
    68331179        -8 2660 2330 2 .
    68333215        -8 2660 2330 1 .
    68344771        -8 2684 2342 2 .
    68351575        -8 2684 2342 2 .
    68367899        -8 2732 2366 1 .
    68427055        -8 2828 2414 1 .
    68427059        -8 2828 2414 1 .
    68561015        -8 3092 2546 1 .
    68561019        -8 3092 2546 2 .
    68595023        -8 3164 2582 2 .
    68596375        -8 3164 2582 1 .
    68624255        -8 3212 2606 1 .
    68624259        -8 3212 2606 1 .
    68680015        -8 3332 2666 1 .
    68680019        -8 3332 2666 1 .
    68690895        -8 3356 2678 2 .
    68705855        -8 3380 2690 2 .
    68705859        -8 3380 2690 2 .
    68740539        -8 3452 2726 2 .
    68740603        -8 3452 2726 2 .
    68740607        -8 3452 2726 1 .
    68808535        -8 3596 2798 1 .
    68813983        -8 3596 2798 1 .
    68813987        -8 3596 2798 2 .
    68815335        -8 3596 2798 2 .
    68901695        -8 3764 2882 2 .
    68901699        -8 3764 2882 2 .
    68903739        -8 3764 2882 2 .
    68903743        -8 3764 2882 2 .
    68928215        -8 3812 2906 2 .
    68963575        -8 3884 2942 1 .
    69007099        -8 3980 2990 1 .
    69053335        -8 4076 3038 2 .
    69070343        -8 4100 3050 1 .
    69075095        -8 4100 3050 2 .
    69075099        -8 4100 3050 1 .
    69078499        -8 4124 3062 2 .
    69083255        -8 4124 3062 2 .
    69083259        -8 4124 3062 2 .
    69105019        -8 4172 3086 1 .
    69111135        -8 4172 3086 2 .
    69118615        -8 4196 3098 2 .
    69172339        -8 4292 3146 1 .
    69172343        -8 4292 3146 1 .
    69183897 121927113  109   26 1 .
    69262775        -8 4484 3242 1 .
    69263451        -8 4484 3242 1 .
    69298135        -8 4556 3278 2 .
    69325335        -8 4604 3302 2 .
    69325339        -8 4604 3302 1 .
    69345055        -8 4628 3314 2 .
    69375651        -8 7078 3322 1 .
    69375655        -8 7078 3322 1 .
    69389255        -8 7098 3322 2 .
    69391295        -8 7101 3322 1 .
    69431415        -8 7161 3324 2 .
    69431419        -8 7161 3324 2 .
    69451135        -8 7190 3324 1 .
    69622489 112447694   72   16 1 .
    69625901 152179399  185   52 1 .
    69667373 122928113  205   61 1 .
    69667377 152240616  205   61 2 .
    69706137 132706571  140   37 1 .
    69727897 152342133   90   20 1 .
    69786369 123234034  175   49 2 .
    69848935        -8 7784 3336 1 .
    69848939        -8 7784 3336 1 .
    69848943        -8 7784 3336 2 .
    69865933 113015895   17    6 2 .
    69865937 162437099   17    6 2 .
    69907415        -8 7870 3337 2 .
    70041377 133440184   12    4 1 .
    70076055        -8 8149 3342 2 .
    70116175        -8 8209 3343 1 .
    70116179        -8 8209 3343 1 .
    70207293 133794245   20    7 1 .
    70231773 153193107   29   10 2 .
    70337175        -8 8537 3349 2 .
    70432373 123801478   34   11 1 .
    70432377 153510048   34   11 1 .
    70484733 153610522  101   23 2 .
    70510573 144007304   34   11 2 .
    end
    label values pid pid
    label def pid -8 "inapplicable", modify
    label values i_psu i_psu
    label values i_strata i_strata
    label values i_sex i_sex
    label def i_sex 1 "male", modify
    label def i_sex 2 "female", modify
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 2809 observations
    Use the count() option to list more

    Best regards

  • #2
    what was your -svyset- command?

    Comment


    • #3
      Dear Rich Goldstein,

      It´is:

      svyset i_psu [pweight=i_indscui_lw], strata (i_strata)

      Can you help me with this? Thank you in advance.

      Comment


      • #4
        at least in your data example, your weight variable (i_indsui_lw) is always missing and that is the problem

        Comment


        • #5
          Dear Rich Goldstein,
          I do believe that I found the error: the command should be svyset i_psu [pweight=i_indscui_xw], strata (i_strata) because of the cross sectional data. Is it corret?
          Thank you in advance.



          ----------------------- copy starting from the next line -----------------------
          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input long(pidp pid i_hidp) byte i_sex float(i_indscui_lw i_indscui_xw) int i_strata long i_psu
          68041499        -8 68176816 2 . . 2042 2084
          68044215        -8 68197216 1 . . 2042 2084
          68046939        -8 68231216 1 . . 2042 2084
          68056463        -8 68258416 2 . . 2054 2108
          68060535        -8 68285616 1 . . 2054 2108
          68063935        -8 68299216 1 . . 2066 2132
          68142143        -8 68578016 1 . . 2138 2276
          68180899        -8 68754816 2 . . 2174 2348
          68191775        -8 68809216 1 . . 2186 2372
          68197223        -8 68836416 1 . . 2198 2396
          68226455        -8 68952016 2 . . 2222 2444
          68228503        -8 68965616 1 . . 2222 2444
          68230539        -8 68979216 1 . . 2222 2444
          68244819        -8 69040416 1 . . 2234 2468
          68247539        -8 69047216 1 . . 2246 2492
          68265219        -8 69094816 2 . . 2258 2516
          68288335        -8 69162816 1 . . 2282 2564
          68293103        -8 69176416 2 . . 2282 2564
          68331179        -8 69319216 2 . . 2330 2660
          68333215        -8 69326016 1 . . 2330 2660
          68344771        -8 69400816 2 . . 2342 2684
          68351575        -8 69428016 2 . . 2342 2684
          68367899        -8 69482416 1 . . 2366 2732
          68427055        -8 69638816 1 . . 2414 2828
          68427059        -8 69638816 1 . . 2414 2828
          68561015        -8 70033216 1 . . 2546 3092
          68561019        -8 70033216 2 . . 2546 3092
          68595023        -8 70148816 2 . . 2582 3164
          68596375        -8 70155616 1 . . 2582 3164
          68624255        -8 70278016 1 . . 2606 3212
          68624259        -8 70278016 1 . . 2606 3212
          68680015        -8 70502416 1 . . 2666 3332
          68680019        -8 70502416 1 . . 2666 3332
          68690895        -8 76398016 2 . . 2678 3356
          68705855        -8 70584016 2 . . 2690 3380
          68705859        -8 70584016 2 . . 2690 3380
          68740539        -8 70699616 2 . . 2726 3452
          68740603        -8 70706416 2 . . 2726 3452
          68740607        -8 70706416 1 . . 2726 3452
          68808535        -8 70937616 1 . . 2798 3596
          68813983        -8 70944416 1 . . 2798 3596
          68813987        -8 70944416 2 . . 2798 3596
          68815335        -8 76486416 2 . . 2798 3596
          68901695        -8 71046416 2 . . 2882 3764
          68901699        -8 71046416 2 . . 2882 3764
          68903739        -8 71053216 2 . . 2882 3764
          68903743        -8 71053216 2 . . 2882 3764
          68928215        -8 71087216 2 . . 2906 3812
          68963575        -8 71202816 1 . . 2942 3884
          69007099        -8 71338816 1 . . 2990 3980
          69053335        -8 71447616 2 . . 3038 4076
          69070343        -8 71522416 1 . . 3050 4100
          69075095        -8 71563216 2 . . 3050 4100
          69075099        -8 71563216 1 . . 3050 4100
          69078499        -8 71576816 2 . . 3062 4124
          69083255        -8 71610816 2 . . 3062 4124
          69083259        -8 71610816 2 . . 3062 4124
          69105019        -8 71665216 1 . . 3086 4172
          69111135        -8 71678816 2 . . 3086 4172
          69118615        -8 71685616 2 . . 3098 4196
          69172339        -8 71896416 1 . . 3146 4292
          69172343        -8 71896416 1 . . 3146 4292
          69183897 121927113 73582816 1 . .   26  109
          69262775        -8 72161616 1 . . 3242 4484
          69263451        -8 72168416 1 . . 3242 4484
          69298135        -8 72270416 2 . . 3278 4556
          69325335        -8 72365616 2 . . 3302 4604
          69325339        -8 72365616 1 . . 3302 4604
          69345055        -8 72413216 2 . . 3314 4628
          69375651        -8 72420016 1 . . 3322 7078
          69375655        -8 72420016 1 . . 3322 7078
          69389255        -8 72426816 2 . . 3322 7098
          69391295        -8 72440416 1 . . 3322 7101
          69431415        -8 72494816 2 . . 3324 7161
          69431419        -8 72494816 2 . . 3324 7161
          69451135        -8 72522016 1 . . 3324 7190
          69622489 112447694 73752816 1 . .   16   72
          69625901 152179399 73773216 1 . .   52  185
          69667373 122928113 73807216 1 . .   61  205
          69667377 152240616 73807216 2 . .   61  205
          69706137 132706571 73827616 1 . .   37  140
          69727897 152342133 73834416 1 . .   20   90
          69786369 123234034 73861616 2 . .   49  175
          69848935        -8 72692016 1 . . 3336 7784
          69848939        -8 72692016 1 . . 3336 7784
          69848943        -8 72692016 2 . . 3336 7784
          69865933 113015895 73922816 2 . .    6   17
          69865937 162437099 73922816 2 . .    6   17
          69907415        -8 72739616 2 . . 3337 7870
          70041377 133440184 74052016 1 . .    4   12
          70076055        -8 72841616 2 . . 3342 8149
          70116175        -8 72868816 1 . . 3343 8209
          70116179        -8 72868816 1 . . 3343 8209
          70207293 133794245 74133616 1 . .    7   20
          70231773 153193107 74194816 2 . .   10   29
          70337175        -8 72943616 2 . . 3349 8537
          70432373 123801478 74276416 1 . .   11   34
          70432377 153510048 74276416 1 . .   11   34
          70484733 153610522 74296816 2 . .   23  101
          70510573 144007304 74303616 2 . .   11   34
          end
          label values pid pid
          label def pid -8 "inapplicable", modify
          label values i_sex i_sex
          label def i_sex 1 "male", modify
          label def i_sex 2 "female", modify
          label values i_strata i_strata
          label values i_psu i_psu
          ------------------ copy up to and including the previous line ------------------

          Listed 100 out of 2809 observations
          Use the count() option to list more

          Best regards

          Comment


          • #6
            you are asking whether something is correct but I'm not sure what that "something" is; however, the weight variable is still missing in each and every observation and thus cannot be correct (unless your real data has non-missing values for this variable)

            Comment


            • #7
              Agreed. Using the full dataset, try
              Code:
              count if !missing(i_indscui_xw)
              If the result is zero, then Rich Goldstein's initial observation is also correct for the whole dataset.
              David Radwin
              Senior Researcher, California Competes
              californiacompetes.org
              Pronouns: He/Him

              Comment

              Working...
              X