Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: algebraic with missings


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: algebraic with missings
Date   Tue, 18 Nov 2003 14:00:08 -0000

Alternatively 

gen negc = -c 
egen q = rsum(a b negc) 

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

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Nick Cox
> Sent: 18 November 2003 13:49
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: algebraic with missings
> 
> 
> With -egen, rsum()- missings are ignored, 
> which evidently is what you want here. 
> 
> If you go 
> 
> . which _grsum 
> 
> and fire up your favourite text editor
> to look at the code, you can see how 
> it is done, by using 
> 
> cond(mi(varname), 0, varname) 
> 
> (In fact, what is there is an older 
> way of saying this; under version control, 
> that's OK.) 
> 
> Another way of doing this is 
> to exploit the fact that max(0, <missing>) 
> is 0 -- but that's not so good if any 
> of your values is negative. 
> 
> You want 
> 
> gen q = cond(mi(a), 0, a) + cond(mi(b), 0, b) - cond(mi(b), 0, c) 
> 
> Can that be written more concisely? 
> 
> Nick 
> n.j.cox@durham.ac.uk 
> 
> Roberto De Miguel
>    
> > To solve an equation of the type:  
> >   
> > p = a + b + c  
> >   
> > where a, b or c can be missing,  
> > I use the following sentence:  
> >   
> > egen p = rsum (a b c)  
> >   
> > But now I want to solve:  
> >   
> > q = a + b - c  
> >   
> > How can I do that?
> 
> *
> *   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