Announcement

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

  • Storing Weighted Counts as a New Variable

    I am working with ACS PUMS data and am trying to estimate the number of foreign born individuals who entered the U.S. in 2002 and 2003 by state. My end goal is to export this into excel as one column of the weighted counts, structured as 50 rows for the 2001 data followed by 50 rows of the 2002 data. An example of a point estimate for a foreign-born person in California who entered the U.S. in 2001 is:

    Code:
    svyset[pw=pwgtp][
    gen ca_yoe02=0
    replace ca_yoe02=1 if nativity==2 & yoep==2002 & st==06
    svy: tab ca_yoe02, count format(%15.2g)
    Here is where I am stuck. First, how can I store this weighted count, or even return it? Using the ereturn command, I see that there are some automatically stored values, but I cannot find the weighted counts here.

    Second, how can I efficiently construct my desired variable (described above). I figured I would use a sequence of the state codes and create a loop using code similar to that above. I'm not sure if this is the right away to go about it, or if I am on the wrong track. I am out of my league at the moment.

    P.S.
    I combed through previous threads on the subject and found some relevant posts, but could not break through my own problem. I saw a similar problem concerning the differences between storing survey data and nonsurvey data, but not for the counts.

  • #2
    Don't use -svy: tab- for this. Use -svy: total ca_yoe02-. Then grab the matrix r(table), and the weighted table will be in the upper left corner of that matrix.

    By the way, your generation of ca_yoe02 is twice as long as it needs to be. All you need is the single line -gen ca_yoe02 = nativity==2 & yoep==2002 & st==06-

    Finally, it is the norm in this community to use our real given names and surnames as our user ID, to promote collegiality and professionalism. You cannot change your user ID by editing your profile. But you can do so by clicking on Contact Us (lower right corner of the page) and messaging the Forum administrator requesting he change it for you. Thank you.

    Comment

    Working...
    X