***
*** Example 1 - Saving, expenditure, and income in Thailand
***
*** The program, which was used to calculate Table 1.3, takes data on income, 
*** expenditure, and weights from a file thaicy.dta, creates a measure of 
*** saving, sorts by income and by expenditure, and creates deciles for 
*** each, taking into account the weights. Income, expenditure, and saving
*** are then summarized by decile.
***
*** Note: The following provides the STATA code used to produce the 
*** results in Table 1-3 of "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
#delimit ;
cap log close;
log using table13, replace;
drop _all;
set more 1;
* data with income, expenditure and weights;
use thaicy;
* remove missing values;
drop if inc1==.;
drop if exp1==.;
* getting the sum of the weights for normalization;
qui summ weight;
global bigw=_N*_result(3); 
*first sorting by household total income;
sort inc1;
gen sumwt=sum(weight)/$bigw;
gen dec=int(sumwt*10)+1;
* puts the richest household in the top decile, not the 11th;
replace dec=10 if dec==11; 
sort dec;
*average saving by deciles of total household income;
by dec: summ sav1 [aweight=weight];
*all;
summ sav1 [aweight=weight];
*average income by deciles of total household income;
by dec: summ inc1 [aweight=weight];
*all;
summ inc1 [aweight=weight];
drop dec sumwt; 
*now repeating by household total expenditure;
sort exp1;
gen sumwt=sum(weight)/$bigw;
gen dec=int(sumwt*10)+1;
replace dec=10 if dec==11; 
sort dec;
*average saving by deciles of total household expenditure;
by dec: summ sav1 [aweight=weight];
summ sav1 [aweight=weight];
*average expenditure by deciles of total household expenditure;
by dec: summ exp1 [aweight=weight];
summ exp1 [aweight=weight]; 
log close; 

 


[Return to Program List]