Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[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 <xuelianstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index