Challenge 3 (Data Management)
Using the household_ea.dta data set that you created in exercise 8, we are going to dig a bit more into the consumption gap between households in rural and urban EAs. We will walk through a number of steps that require you to use the concepts and commands from earlier in Assignment 3.
- Start by using
gento create a variable calledgapthat equals 1 if the household’s consumption gap is negative. Thenreplacethe value ofgapso that it equals 0 if the household’s consumption gap is positive.- Hint: there are a number of households with missing values because either the household or EA data was missing. For reasons that are not important, Stata treates a missing value (the sysmis
.) as positive infinity. So if you were to just typereplace gen = 0 if cons_gap > 0Stata will assign a 0 to household above the mean consumption but also to all households with missing values. So you need to add an additional conditional aboutcons_gapnot equalling.
- Hint: there are a number of households with missing values because either the household or EA data was missing. For reasons that are not important, Stata treates a missing value (the sysmis
- Label the variable as
Indicator for sign of consumption gap. Also define a value label calledgap_lblwhere 0 isPositive Gapand 1 isNegative Gap. Assign this value label to thegapvariable. - Use
egento create a variable calledbelowthat totals up all households withgap = 1. Do this byeaidandsector. Label the variableNumber of households below mean consumption. - Use
egento create a variable calledabovethat totals up all households withgap = 0. Do this byeaidandsector. Label the variableNumber of households above mean consumption.- Hint: when having Stata total up households with a positive gap, you need to explicitly tell Stata to count the households where
gap == 0.
- Hint: when having Stata total up households with a positive gap, you need to explicitly tell Stata to count the households where
- Use
egento create a variable calledtot_hhthat counts up all households in an EA and sector. Label the variableTotal number of households in EA. - Use
gento create a variable calledshare_belowthat is the percentage of households with a negative consumption gap within an EA and sector. Label the variablePercentage of households in EA below mean consumption.
Now that we have all these variables created and labeled, we can ask questions about where the gap is most negative or most positive using bys in combination with sum.
- Is the share of households with a negative consumption gap greater in urban or rural EAs?
- Which country has the largest share of households with a negative consumption gap?
- Which country has the smallest share of households with a negative consumption gap?