The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Wealth Index » identifying households with a servant
identifying households with a servant [message #3891] Mon, 02 March 2015 06:59 Go to next message
cpfeifer is currently offline  cpfeifer
Messages: 10
Registered: January 2015
Location: Kenya
Member
Hello
I am trying to construct the variable "household has a servant"
So I am extracting the data of HV101 (.01-.22), relation to the head of household in the household data, as well as V705 and V717 the women or her husband's.

Any suggestion on how i can link the two datasets? and if possible, what R function can i use to link them?
Thanks a lot!
Re: identifying households with a servant [message #3904 is a reply to message #3891] Wed, 04 March 2015 12:19 Go to previous messageGo to next message
Liz-DHS
Messages: 1516
Registered: February 2013
Senior Member
Dear User,
I have forwarded your query to one of our experts. Will have an answer for you as soon as it is available.
Thank you!
Re: identifying households with a servant [message #4056 is a reply to message #3904] Tue, 24 March 2015 10:31 Go to previous messageGo to next message
Ogriv is currently offline  Ogriv
Messages: 16
Registered: March 2015
Member
Hello - I'm interested in creating the same variable.

Was there ever an expert answer to this?

Thanks
Sandra
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 next message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 795
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

Re: identifying households with a servant [message #4141 is a reply to message #4133] Tue, 07 April 2015 08:31 Go to previous message
cpfeifer is currently offline  cpfeifer
Messages: 10
Registered: January 2015
Location: Kenya
Member
Thanks a lot! this helps me further!

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


Current Time: Sun May 26 08:29:23 Coordinated Universal Time 2024