Statalist The Stata Listserver


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

RE: st: combining two variables


From   "Moore, Jesse" <Jesse.Moore@vtmednet.org>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: combining two variables
Date   Wed, 7 Mar 2007 19:28:28 -0500

Thanks, I've figured it out by reading everyone's comments.  Very
helpful!

JSM 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Wednesday, March 07, 2007 16:50
To: statalist@hsphsun2.harvard.edu
Subject: RE: st: combining two variables

Tell us your rules, and we'll suggest some code. 

Nick
n.j.cox@durham.ac.uk 

Moore, Jesse
 
> Will this work for more than two variables?  I'm working with a 
> similar situation, but with 7 variables.

Nick Cox

> Some very complicated solutions here! 
> 
> Consider:
> 
> gen newvar = max(var1, var2) if missing(var1, var2)
> 
> Logic: 
> 
> If just one of var1 or var2 is missing, then -missing()- will return 
> true.
> 
> In that case, max(var1, var2) will
> return the non-missing value in question. 
> 
> If both are missing, then you get missing returned, but that is fair 
> enough.
> 
> If neither is missing, missing is returned. 

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


Confidentiality Notice:
This message, and any attachments, may contain information that is confidential, privileged, and/or protected from disclosure under state and federal laws that deal with the privacy and security of medical information. If you received this message in error or through inappropriate means, please reply to this message to notify the Sender that the message was received by you in error, and then permanently delete this message from all storage media, without forwarding or retaining a copy.

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