jeudi 7 mai 2015

Mutually exclusive conditionals doesn't work in STATA

I have some data on STATA with some variables like "logTA" and "class". I have more than a thousand observations and logTA doesn't have any nonmissing values. Data looks like this:

logTA       class
--------    --------
.           
.           
21.26871    
.           

Now, what I want to do is to assign values to "class" variable according to the following simple rules:

replace class = 1 if logTA < mean(logTA) - sd(logTA)
replace class = 2 if logTA >= mean(logTA) - sd(logTA) & logTA < mean(logTA) + sd(logTA)
replace class = 3 if logTA >= mean(logTA) + sd(logTA)

It looks simple but STATA doesn't have mean() and sd() functions that can be used in this way. Anyway, I replaced mean(logTA) with 19.76543 and sd(logTA) with 1.507828.

However, among many a thousand of observations, the observation with logTA = 21.26871 isn't assigned any class. How this could be possible when my conditionals are mutually exclusive.

Aucun commentaire:

Enregistrer un commentaire