# HHWT for a person variable

**URL:** <https://forum.ipums.org/t/hhwt-for-a-person-variable/1671>\
**Category:** USA\
**Created:** [March 28, 2017, 8:52pm UTC](https://forum.ipums.org/t/hhwt-for-a-person-variable/1671 "2017-03-28T20:52:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunnyacres65](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/sunnyacres65/32/264_2.png) [@sunnyacres65](https://forum.ipums.org/u/sunnyacres65)\
**Post date:** [March 28, 2017, 8:52pm UTC](https://forum.ipums.org/t/hhwt-for-a-person-variable/1671/1 "2017-03-28T20:52:00Z")

</div>

We are looking to get a total of Households that have a student aged 15-19 years. Can I total the HHWT based upon those in that age range attending school? Or, can you only total the PERWT since it is a person variable? I assume households will have multiple students so I would expect those numbers to be lower than the PERWT total, and it is, but didn’t know if you can mix the H’s with the P’s!

Thanks much!

---

<div class="post-metadata">

**Author:** ![skolenik](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/skolenik/32/201_2.png) [@skolenik](https://forum.ipums.org/u/skolenik)\
**Post date:** [March 28, 2017, 9:18pm UTC](https://forum.ipums.org/t/hhwt-for-a-person-variable/1671/2 "2017-03-28T21:18:00Z")

</div>

gen byte \_is\_student\_15to19 = inlist(school,2) & inrange(age,15,19)

egen \_hh\_has\_student\_15to19 = max( \_is\_student\_15to19 ), by( serial )

egen hh\_tag = tag( serial )

svyset [pw=hhwt], vce(sdr) sdrweight( rephhwt1 - rephhwt120 )

svy : total \_hh\_has\_student\_15to19 if hh\_tag

Not sure I got the replicate weights right, but this should be fixable. The range of variables is a \*very\* dangerous piece of syntax. Note that sdrweight( rephhwt\* ) syntax will unfortunately pick up the rephhwt flag indicating the presence of replicate weights for the given case, and that’s not what you want. If you want bulletproof, or simply are paranoid like myself,

local repwtlist

forvalues k=1/120 {

local repwtlist `repwtlist' rephhwt`k’

}

svyset … , sdrw( `repwtlist’ )

IPUMS microdata format is in some ways unfortunate as it mixes household and person data files, and has two weight variables. I see how this can be confusing. While I nearly always say that svy commands should use subpop() when they need to restrict the sample, note that the use of -svy : command if selection- is appropriate here: it subsets the sample to one case per HH before sending it to svy, untangling the issue of the pooled HH and person level data.

---

<div class="post-metadata">

**Author:** ![sunnyacres65](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/sunnyacres65/32/264_2.png) [@sunnyacres65](https://forum.ipums.org/u/sunnyacres65)\
**Post date:** [March 28, 2017, 9:36pm UTC](https://forum.ipums.org/t/hhwt-for-a-person-variable/1671/3 "2017-03-28T21:36:00Z")

</div>

I appreciate the response, but I feel really stupid. I have no idea how to translate your recommendation! Help!

---

<div class="post-metadata">

**Author:** ![JeffBloem](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/jeffbloem/32/40_2.png) [@JeffBloem](https://forum.ipums.org/u/JeffBloem)\
**Post date:** [March 30, 2017, 4:26pm UTC](https://forum.ipums.org/t/hhwt-for-a-person-variable/1671/4 "2017-03-30T16:26:00Z")

</div>

Essentially what you’ll want to do here is create a household level variable that indicates if the household has a student attending school between the ages of 15-19. Then to produce an estimate of the population, you should apply the HHWT variable. You can certainly get fancy with the calculation of your standard errors around your estimates by using replicate weights, but it may not be necessary for your purposes. [See this page](https://usa.ipums.org/usa/voliii/ACSsamp.shtml) for more information on the ACS sampling design. [See this page](https://usa.ipums.org/usa/repwt.shtml) for more information on replicate weights.

---

<div class="post-metadata">

**Author:** ![sunnyacres65](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/sunnyacres65/32/264_2.png) [@sunnyacres65](https://forum.ipums.org/u/sunnyacres65)\
**Post date:** [March 30, 2017, 4:28pm UTC](https://forum.ipums.org/t/hhwt-for-a-person-variable/1671/5 "2017-03-30T16:28:00Z")

</div>

Great, thank you! It does seem to check out as far as the numbers go for the HHWT variable, but for some reason I started to second-guess myself. Thank you very much!
