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 at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Creating a new variable conditional on the values for 2 other variables


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Creating a new variable conditional on the values for 2 other variables
Date   Tue, 10 May 2011 08:34:44 +0100

On Tue, May 10, 2011 at 2:08 AM, Hitesh Chandwani
<chandwanihitesh@mail.utexas.edu> wrote:
> Thank you, Christian! This works!
>
> -Hitesh
>
>
> On May 9, 2011, at 7:57 PM, Christian Holz (Stata list) wrote:
>
>> Hi,
>>
>> generate C=A
>> replace C=B if !missing(B)
>>
>> Best,
>> C
>>
>> On Mon, May 9, 2011 at 8:50 PM, Hitesh Chandwani
>> <chandwanihitesh@mail.utexas.edu> wrote:
>>>
>>> Dear Statalisters,
>>>
>>> I am looking for a solution to the following problem.
>>>
>>> I have 2 variables, A and B. I have values of A for all observations and
>>> values of B for some. A and B are both cost variables such that
>>> (B=A+extra
>>> cost). I need to generate a new variable C, such that C=B (for
>>> observations
>>> having a value for B), otherwise C=A
>>>
>>> I'd be highly obliged if I get a solution to this problem.
>>>
>>> Regards,
>>> Hitesh S. Chandwani
>>> chandwanihitesh@mail.utexas.edu
>>>
>>>
>>>
>>> *
>>> *   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/
>>>
>>
>> *
>> *   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/
>
> *
> *   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/
>

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