[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
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,
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.
gen q = cond(mi(a), 0, a) + cond(mi(b), 0, b) - cond(mi(b), 0, c)
Can that be written more concisely?
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: