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: Mata question on replacing missing values


From   Matthew Baker <matthew.baker@hunter.cuny.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Mata question on replacing missing values
Date   Thu, 22 Dec 2011 09:45:21 -0500

Dear Listers:

     I am curious if there is a simple solution to the following
problem in Mata. I have two vectors (call them X and Y). X has missing
values, while Y does not. What I would like to do is make a third
vector, Z, which is composed of X when the value of X is not missing,
and Y otherwise. For example, if I have X=(5,6,.,.,4)', and
Y=(1,5,3,2,3)', I would like Z to be Z=(5,6,3,2,4)'. In order:


: X,Y,Z
       1   2   3
    +-------------+
  1 |  5   1   5  |
  2 |  6   5   6  |
  3 |  .   3   3  |
  4 |  .   2   2  |
  5 |  4   3   4  |
    +-------------+

Is there a simple solution?

Thanks in advance,

Matt Baker

-- 
Dr. Matthew J. Baker
Department of Economics
Hunter College and the Graduate Center, CUNY
*
*   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