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

From |
"Joseph Coveney" <jcoveney@bigplanet.com> |

To |
"Statalist" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: Creating a variable with the highest value from two other |

Date |
Sat, 13 Oct 2007 17:23:35 -0700 |

Christer Thrane wrote: I can't get it to work. Can you se what is wrong in the assert-command [snip] . assert !missing(X) & !missing(Y) 108 contradictions in 467 observations assertion is false r(9); . generate byte Zstar = cond((X >= Y), X, Y) (108 missing values generated) [snip] -------------------------------------------------------------------------------- Nothing is wrong with the -assert-. I put it there in order to abort the do-file should there be missing values. But you have missing values. The first item of business is to decide how you want to handle observations with missing values. You can set Z to missing, set it to the nonmissing value of X and Y (like a COALESCE statement in SQL), or do something else of your choosing. To set Z to missing, use the code as suggested: generate long Z = cond((X>=Y), X, Y) // Be sure the data type is adequate Otherwise, use nested -cond()- as suggested: generate long cond(missing(X), cond(missing(Y), /// ., Y), cond((X>=Y), X, Y)) Joseph Coveney * * 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/

- Prev by Date:
**Re: st: Creating a variable with the highest value from two other variables** - Next by Date:
**Re: st: Creating a variable with the highest value from two other** - Previous by thread:
**st: Problems with downloading midas** - Next by thread:
**Re: st: Creating a variable with the highest value from two other** - Index(es):

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