I am writing because of a problem with the way STATA is interpreting a
'do' file written to create a variable that assigns a weight to each
respondent in my sample (hh survey data), based on their age and
position within a household.
The program is copied below - but the basic problem is that rather than
assigning a value of e.g. .3 to an observation, STATA assigns .30000001.
It does the same for all other decimal weights that are not preceded by
a number before the decimal point (i.e. 1.2 is given as 1.2; but .8 is
.80000001).
I would be very grateful for any advice or possible solutions. (I do not
want to simply round the weights, because I will need to use them in
subsequent calculations).
Here is a copy of the do-file:
*Create famweight variable (this is based on respondent's position in
their household and age). PCO1 describes the relationship to household
head.
gen famweight = 1.2 if pco1==1
replace famweight = .8 if pco1==2
replace famweight = .8 if (3<=pco1 & pco1<=11) & edad >=11
replace famweight = .4 if (3<=pco1 & pco1<=11) & (5<=edad & edad<=10)
replace famweight = .3 if (3<=pco1 & pco1<=11) & (0<=edad & edad<=4)
tab famweight
Many thanks,
Emma Samman
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/