Announcement

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

  • Generating counts from survey weighted data.

    Hi there,

    I am wanting to generate a stata dataset that consists of weighted counts, including the standard error of the weighted counts.
    I am using NIS (national inpatient sample) data to estimate national hospitalization rates.

    To me, the most efficient way to obtain the weighted counts of 'hospitalisations' (by age group and sex) is to use the collapse command as follows:
    collapse (sum) hospital_visit [pweight=finalwt], by(age_4 sex)

    But this command does not allow me to retain the SE of the weighted counts.

    The following command, however, allows me to estimate counts and SE, but I do not know how to export this information into a stata dataset that has weighted counts and SE of weighted counts, by age and sex

    svyset [pweight=finalwt], psu(hospid) strata(nis_stratum) vce(linearized) singleunit(certainty)
    svy, subpop(if sex==1): total hospital_visit, over(age_4)


    I have several files I want to merge, and so am looking for an efficient way to keep them all in stata datasets, rather than exporting to excel, for example, and then converting back to stata.

    Any help would be appreciated.

    Jess


  • #2
    First, the -over()- option allows a list of variables, not just a single variable. So you can specify -over(age_4 sex)- just as you did in the -by()- option of your -collapse- command.

    Next, -total- leaves behind a matrix of coefficients, standard errors, test statistics, p-values, and confidence limits in -r(table)- So you can just collect that matrix with -matrix M = r(table)- immediately after the -svy: total- command. To make a Stata data set of the results, use the -svmat- command.

    I have several files I want to merge, and so am looking for an efficient way to keep them all in stata datasets, rather than exporting to excel, for example, and then converting back to stata.
    I don't understand what this has to do with your question.

    Comment

    Working...
    X