Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: problem with stata misreading decimals

From   "Emma Samman" <[email protected]>
To   <[email protected]>
Subject   st: problem with stata misreading decimals
Date   Wed, 23 Apr 2003 15:53:31 +0100

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

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
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:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index