| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: combining two variables
Eleanor
While there is probably a faster way, I gen temporary variables and recode
the missing:
gen var1a = var1
gen var2a = var2
recode var1a var2a (. = 0)
gen newvar = var1a + var2a
drop var1a var2a
Andrew Sidman
Stony Brook University
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of [email protected]
Sent: Wednesday, March 07, 2007 11:19 AM
To: [email protected]
Subject: st: combining two variables
Thank you to everyone who answered my last question on
creating a variable corresponding to the row number.
Now I have a question about combining the data from two
variables (in the same data set) into one variable. I want to
combine the variables in such a way that the data from one
variable can replace the missing values from the other. I have
created an example of what I am looking for below:
Have: Want:
var1 var2 newvar
. 2 2
. 8 8
. 0 0
7 . 7
3 . 3
. . .
Any thoughts on how to do this?
Thanks
Eleanor Friedman
*
* 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/
*
* 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/