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]

From |
Nick Cox <n.j.cox@durham.ac.uk> |

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

Subject |
st: RE: Understanding the mechanics of the sum() function |

Date |
Mon, 14 Nov 2011 10:46:00 +0000 |

`a' and `b' I take to be quite secondary here. There is a difference as -sum(`exp')- is affected by what is in the current observation if `exp' is so affected, and will return 0 in circumstances in which `exp' + what's inherited will return missing. For example set set obs 10 gen z = . local a 0 local b 1 local exp z generate y1 = `a' + `b' * sum(`exp') gen y2 = . replace y2 = `a' + `b' * (`exp' + cond(missing(y2[_n-1]), 0, y2[_n-1])) l I doubt you could make your code faster as your code requires more interpretation. Nick n.j.cox@durham.ac.uk Billy Schwartz Is there a difference between . generate y = `a' + `b' * sum(`exp') and . generate y = . . replace y = `a' + `b' * (`exp' + cond(missing(y[_n-1]), 0, y[_n-1])) where `a', `b', and `exp' are arbitrary Stata expressions? If they're not the same, is there a way of modifying the second to make it the same as the first? (If they're the same in effect, is one faster than the other?) * * * 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/

**References**:**st: Understanding the mechanics of the sum() function***From:*Billy Schwartz <wkschwartz@gmail.com>

- Prev by Date:
**RE: st: Multinomial Logit Model - Cramer Ridder Test** - Next by Date:
**st: RE: Normal CDF** - Previous by thread:
**st: Understanding the mechanics of the sum() function** - Next by thread:
**st: Re: multistage sample survey and coding** - Index(es):