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: replace missing values of a variable with the median of that variable based on particular criterion
From
xueliansharon <[email protected]>
To
[email protected]
Subject
st: replace missing values of a variable with the median of that variable based on particular criterion
Date
Sat, 11 Aug 2012 12:56:54 -0700 (PDT)
Dear all,
I have two variables Inc (labeled as income) and Range on respondent-level.
For each respondent, if Inc<., then Range=.;
if Inc=., then Range is nonmissing, and provides the range of income for
that respondent (Range=1 means 0<=Inc<200, Range=2 means 200<=Inc<600 ).
The data structure is like:
PersonID Inc Range
1 100 .
2 . 1
3 200 .
4 . 2
5 232 .
6 500 .
7 150 .
8 340 .
9 . 1
10 55 .
I want to realize the following procedure to replace the missing values of
Inc:
When Inc=. & Range=1, replace the missing value of Inc with the median
income of those respondents who provide nonmissing values for Inc and 0<=
Inc<200;
When Inc=. & Range=2, replace the missing value of Inc with the median
income of those respondents who provide nonmissing values for Inc and
200<=Inc<600.
How to realize this purpose?
Thank you very much for your help.
Best,
Sharon
--
View this message in context: http://statalist.1588530.n2.nabble.com/replace-missing-values-of-a-variable-with-the-median-of-that-variable-based-on-particular-criterion-tp7580236.html
Sent from the Statalist mailing list archive at Nabble.com.
*
* 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/