Announcement

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

  • Working with survey data: using weights in svy: proportion

    Hi,

    I've recently started to work more with survey data, and discovered Stata's survey functions. However, I am having trouble with the svy:proportion method.
    I have svyset my dataset and then, having collected my dependent and independent variables in local macros, I expected this following code to run:

    Code:
    svyset [pw=Weight],strata(Region) singleunit(certainty)
    local depvar [InEmp UnEmp]
    local indvars [ib1.age ib1.ethgrp ]
    
    svy: proportion `depvar'
    
    matrix result=r(table)
    
    local n=e(N)
    
    matrix `depvar'=J(1,9,.)
    matrix colnames `depvar'="Percentage" "SE" "Lower95%" "Upper95%" "Difference" "SE" "Pvalue" "stars" "Base"
    matrix `depvar'[1,1]=result[1,2]*100
    matrix `depvar'[1,2]=result[2,2]*100
    matrix `depvar'[1,3]=result[5,2]*100
    matrix `depvar'[1,4]=result[6,2]*100
    matrix `depvar'[1,9]=`n'
    But it does not run, I get the error that "weigths are not allowed". So then I changed my first line of code, taking out the pw=Weight command, but it still won't run.

    I looked at the manual, and there is probably a very simple fix, but I can't see it right now. Any ideas?

    Thank you in advance

  • #2
    local depvar [InEmp UnEmp]
    should be

    Code:
    local depvar InEmp UnEmp

    Brackets in Stata syntax are read as weights.

    Comment


    • #3
      Thank you! I knew it was something silly like that.

      Comment

      Working...
      X