Statalist The Stata Listserver


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

st: Re: setting missing values to random numbers


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: setting missing values to random numbers
Date   Wed, 21 Mar 2007 07:56:18 -0400

replace origred=round(uniform()) if origred==.

M Blasnik

----- Original Message ----- From: "ROBERT BOZICK" <[email protected]>
To: <[email protected]>
Sent: Tuesday, March 20, 2007 4:33 PM
Subject: st: setting missing values to random numbers



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.
*
*   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