Statalist The Stata Listserver


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

Re: st: combining two variables


From   "Paswel Phiri Marenya" <ppm3@cornell.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: combining two variables
Date   Wed, 7 Mar 2007 11:51:23 -0500 (EST)

What to me is easier is something like:

gen var3 = var2
then replace var3=var1 in 4/5 and so on...although with a long data set it
may be tedious perhaps.
regrads
PPm

> 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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index