Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: recode min missings


From   Miguel Portela <[email protected]>
To   [email protected]
Subject   st: recode min missings
Date   Tue, 7 Feb 2006 00:10:32 +0000

Dear all,

I am using the command 'recode' combined with 'min' and an 'if' condition. When
the 'if' condition is not met for at least one observation the recoded variable
is replaced with missings. The following example shows the problem:

************************************
clear
set seed 444555666
set obs 20
gen y=int(uniform()*10)
gen x=uniform()
sort y x
l
preserve
*** 1st alternative
recode y min/3=-999 if x<0
l
restore
preserve
*** 2nd alternative
recode y min/3=-999 if x<.2
l
restore
*** 3rd alternative
recode y 0/3=-999 if x<0
l
*** 4th alternative
recode y 0/3=-999 if x<0.2
l
************************************

After the 1st recode I get the message '(y: 0 changes made)', but when I list
the variables all the values of y have been replaced by missings. In this case
by construction the criteria x<0 is never met. If the criteria is satisfied by
at least one observation, 2nd alternative, the recode combined with 'min' and
'if' works fine. If I replicate the 1st alternative, but use the actual minimum
instead of 'min' the command produces the expected results. Alternative 4
produces the same results as alternative 2.

Could you please let me know what might be behind the missings generated in
alternative 1?

Thank you in advance for your time,

Kind regards,

Miguel


-- 
Escola de Economia e Gest�o
Universidade do Minho
Campus de Gualtar
4710 - 057 Braga
Portugal
Tel. +351 253 604100, Ext. 5557
Fax. +351 253 676375 
*
*   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/



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