The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Wealth Index » identifying households with a servant
Re: identifying households with a servant [message #4133 is a reply to message #4056] Fri, 03 April 2015 08:15 Go to previous messageGo to previous message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 805
Registered: January 2013
Senior Member
Here is some code in R that merges datasets, constructs the variable, and then aggregates to the household level:

library(foreign)
setwd("C:/Data/DHS_stata/")

# read the Individual Recode (IR) dataset
ir <- read.dta("DRIR61FL.dta", convert.factors = FALSE)
# read the Person's Recode (PR) dataset
pr <- read.dta("DRPR61FL.dta", convert.factors = FALSE)

# create a subset of the IR dataset
ir_subset <- ir[c("caseid","v001","v002","v003","v005","v034","v705","v717")]
# create a subset of the PR dataset
pr_subset <- pr[c("hhid","hv001","hv002","hv003","hv005","hvidx","hv101","hv102","hv103")]

# merge the IR subset variables onto the PR subset by the key variables, keeping all PR cases
prir <- merge(pr_subset, ir_subset, by.x = c("hv001","hv002","hvidx"), by.y = c("v001","v002","v003"), all.x=TRUE )

# Create the servant variable
# If the person is coded as a servant or house maid according to the relationship code
prir$servant <- ifelse(prir$hv101==16, 1, 0)
# If the person works as a domestic household worker and is not related to the head of the household
prir$servant[prir$v705==6 & prir$hv101==12] <- 1
# If the person's husband works as a domestic household worker, and is listed in the household (v034), and is not related to the head of the household according to their record
prir$servant[prir$v717==6 & prir$v034 > 0 & prir$hv101[which(prir$hvidx > 0)-prir$hvidx+prir$v034]==12] <- 1

# aggregate from household members to produce the variable servant for each household
hh <- aggregate(prir[c("hv001","hv002","servant")], by=list(prir$hhid), max)
head(hh)


Note, though, that there are very few servants (if any) in most DHS surveys, and it is not clear that it is worth it to use this variable.

[Updated on: Fri, 03 April 2015 08:21]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Computing for Wealth Index
Next Topic: how to compute wealth index in statw
Goto Forum:
  


Current Time: Mon Aug 11 09:46:28 Coordinated Universal Time 2025