Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: AW: RE: AW: recode 9, 99, 999,..., into missing
From
"Lachenbruch, Peter" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: AW: RE: AW: recode 9, 99, 999,..., into missing
Date
Sun, 16 May 2010 16:01:13 -0700
It doesn't, but the 'real values' issue must come from external information, doesn't it? If all i see is 9 or 99 or 999, then the value must be a missing. It may be that we know that the range is such that these may be real and the missing must be 999 (or etc.).
________________________________________
From: [email protected] [[email protected]] On Behalf Of Martin Weiss [[email protected]]
Sent: Sunday, May 16, 2010 8:52 AM
To: [email protected]
Subject: st: AW: RE: AW: recode 9, 99, 999,..., into missing
<>
" Maybe I'm missing the point, but couldn't mvdecode handle this with three
calls?"
But how does -mvdecode- address Amanda`s main concern that "9" or "99" might
be a real value instead of indicating some non-response?
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Lachenbruch,
Peter
Gesendet: Sonntag, 16. Mai 2010 17:13
An: [email protected]
Betreff: st: RE: AW: recode 9, 99, 999,..., into missing
Maybe I'm missing the point, but couldn't mvdecode handle this with three
calls?
mvdecode var3,mv(9/.)
You may want to consider special missings for notanswered and refuse to
answer and etc.
________________________________________
From: [email protected]
[[email protected]] On Behalf Of Martin Weiss
[[email protected]]
Sent: Sunday, May 16, 2010 8:10 AM
To: [email protected]
Subject: st: AW: recode 9, 99, 999,..., into missing
<>
Not sure whether this is totally foolproof, try it yourself :-) -mod()- just
has to part of the solution, I think:
*************
clear*
inp byte(var1 var2) int(var3 var4)
1 1 1 1
2 2 2 2
3 3 3 3
4 8 99 999
5 9 100 1000
6 10 101 1001
7 11 150 5000
9 12 999 9999
end
foreach var of varlist *{
sum `var', mean
local notanswered = cond((mod(r(max),9)==0),r(max),.)
if !mi(`notanswered') replace `var'=. if `var'==`notanswered'
}
list, noo
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Amanda Fu
Gesendet: Sonntag, 16. Mai 2010 16:57
An: [email protected]
Betreff: st: recode 9, 99, 999,..., into missing
Hi all,
I have seen a couple of times that for some data sets the "not
answered" is coded as 9, 99, 999...... and the number of digit of 9
depends on the number of digit of the maximum value of the variable.
It is convenient to analyze if recoding them into missing. But the
problem is, for some variables, 9 or 99 might be the real values. I
was wondering if there is any good way to deal with this kind of
recoding.
(In the past we have a discussion thread of using the value label
information such as "not answered" to deal with this question. What I
am asking here is what if there are no such value labels ?)
For example, here are three variables :
var1 takes values: {1,2,3,4,9}
where 9 means "not answered"
var2 takes values: {1,2,3,......8,9,10,11,12,99}
where 99 means " "not answered"
var3 takes values: {1,2,3,...99,100,101,..,150,999} where
999 means " "not answered"
var4 takes values: {1,2,3,...999,1000,1001,..5000,9999} where 9999
means " "not answered"
Now I am thinking to recode int he following way:
foreach var of varlist * {
sum `var'
replace `var'=. if r(max)<9 & `var'==9
replace `var'=. if r(max)<99 & r(max)>9 & `var'==99
replace `var'=. if r(max)<999 & r(max)>99 & `var'==999
replace `var'=. if r(max)<9999 & r(max)>999 & `var'==9999
}
I would like to hear if anyone has better method instead of this.
Thanks for your time!
Best wishes,
Amanda
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/