***
*** Example 3.1. Consumption measures for Côte d'Ivoire (Table 3.1)
***
*** The code uses data on household expenditures, prices, and 
*** weights to calculate means for households and individuals, 
*** as well as their standard errors taking into account the survey design.
*** 
*** Note: The following provides the STATA code used to produce 
*** results used in "The Analysis of Household Surveys: 
*** A Microeconometric Approach to Development Policy", by Angus Deaton.
*** This book, published for the World Bank by The Johns Hopkins University
*** Press and scheduled for release in 1997.
***
version 4.0
/* NB the code uses the survey commands incorporated into the main
code from version 5.0 of STATA */
#delimit ;
drop _all;
cap log close;
log using table31.log, replace;
use c:\cdi1996\1985dta\hhexp85;
matrix prices=(100,107.3,107.75,115.31\92.84,100.45,98.58,106.74\
87.01,93.36,94.95,99.84\78.25,80.11,81.50,83.51\
75.97,85.97,88.20,94.42);
/*
**These are the prices reported on p 49 of the CLISS documentation
**Rows are regions, Abidjan, Other Cities, EForest, WForest, Savannah
** Columns are 1985, 1986, 1987, 1988
*/
matrix prices=prices*.01;
gen hhid=clust*100+nh;
ren reg region;
ren hhsize5 hhs;
keep hhid region hhexp hhs clust;
replace hhexp=hhexp/1000;
replace hhexp=hhexp/prices[1,1] if region==1;
replace hhexp=hhexp/prices[2,1] if region==2;
replace hhexp=hhexp/prices[3,1] if region==3;
replace hhexp=hhexp/prices[4,1] if region==4;
replace hhexp=hhexp/prices[5,1] if region==5;
gen year=1985;
sort hhid;
save temp, replace;
use c:\cdi1996\1985dta\weight85;
gen hhid=clust*100+nh;
keep hhid allwaitn;
sort hhid;
merge hhid using temp;
tab _m; drop _m;
gen pce=hhexp/hhs;
sort hhid;
save temp, replace;
drop _all; 
use c:\cdi1996\1986dta\hhexp86;
gen hhid=clust*100+nh;
ren reg region;
ren hhsize6 hhs;
keep hhid region hhexp hhs clust;
replace hhexp=hhexp/1000;
replace hhexp=hhexp/prices[1,2] if region==1;
replace hhexp=hhexp/prices[2,2] if region==2;
replace hhexp=hhexp/prices[3,2] if region==3;
replace hhexp=hhexp/prices[4,2] if region==4;
replace hhexp=hhexp/prices[5,2] if region==5;
gen year=1986;
sort hhid;
save tempa, replace;
use c:\cdi1996\1986dta\weight86;
gen hhid=clust*100+nh;
keep hhid allwaitn;
sort hhid;
merge hhid using tempa;
tab _m; drop _m;
gen pce=hhexp/hhs;
append using temp;
save temp, replace; 
use c:\cdi1996\1987dta\hhexp87;
gen hhid=clust*100+nh;
ren reg region;
ren hhsize7 hhs; 
keep hhid region hhexp hhs clust;
replace hhexp=hhexp/1000;
replace hhexp=hhexp/prices[1,3] if region==1;
replace hhexp=hhexp/prices[2,3] if region==2;
replace hhexp=hhexp/prices[3,3] if region==3;
replace hhexp=hhexp/prices[4,3] if region==4;
replace hhexp=hhexp/prices[5,3] if region==5;
gen year=1987;
sort hhid;
save tempa, replace;
use c:\cdi1996\1987dta\weight87;
gen hhid=clust*100+nh;
keep hhid allwaitn;
sort hhid;
merge hhid using tempa;
tab _m; drop _m;
gen pce=hhexp/hhs;
append using temp;
save temp, replace; 
use c:\cdi1996\1988dta\hhexp88;
gen hhid=clust*100+nh;
ren reg region;
ren hhsize8 hhs;
keep hhid region hhexp hhs clust;
replace hhexp=hhexp/1000;
replace hhexp=hhexp/prices[1,4] if region==1;
replace hhexp=hhexp/prices[2,4] if region==2;
replace hhexp=hhexp/prices[3,4] if region==3;
replace hhexp=hhexp/prices[4,4] if region==4;
replace hhexp=hhexp/prices[5,4] if region==5;
gen year=1988;
sort hhid;
save tempa, replace;
use c:\cdi1996\1988dta\weight88;
gen hhid=clust*100+nh;
keep hhid allwaitn;
sort hhid;
merge hhid using tempa;
tab _m; drop _m;
gen pce=hhexp/hhs;
append using temp;
save cdi85_88, replace; 
tab year; 
varset strata region;
varset psu clust;
varset pweight allwaitn; 
svymean hhexp if year==1985;
svymean hhexp if year==1986;
svymean hhexp if year==1987;
svymean hhexp if year==1988; 
svymean hhs if year==1985;
svymean hhs if year==1986;
svymean hhs if year==1987;
svymean hhs if year==1988; 
svymean pce if year==1985;
svymean pce if year==1986;
svymean pce if year==1987;
svymean pce if year==1988; 
svyratio hhexp/hhs if year==1985;
svyratio hhexp/hhs if year==1986;
svyratio hhexp/hhs if year==1987;
svyratio hhexp/hhs if year==1988; 
gen combwt=allwaitn*hhs;
varset pweight combwt;
svymean pce if year==1985;
svymean pce if year==1986;
svymean pce if year==1987;
svymean pce if year==1988;

log close; 

 


[Return to Program List]