Statalist The Stata Listserver


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

st: setting missing values to random numbers


From   ROBERT BOZICK <rbozick@jhu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: setting missing values to random numbers
Date   Tue, 20 Mar 2007 16:33:37 -0400

Hello,

I am working on recoding a categorical variable (orig) with 10 values into a binary variable (origred) coded  0,1.

gen origred = .
replace origred = 0 if orig >=1  & orig <=5
replace origred = 1 if orig >5    & orig <=10

There are a number of missing values for the original variable orig.

Is there a way to have Stata randomly assign those missing values to either a 0 or a 1 in the new variable origred?  I am completely stumped.

Thanks in advance!

Robert

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index