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: Mata question on replacing missing values
From
Matthew Baker <[email protected]>
To
[email protected]
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/