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

From |
Kit Baum <kitbaum@mac.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: sum |

Date |
Mon, 31 Oct 2005 12:21:07 -0500 |

Dirk wrote

I want to assign a dummy if the id (1,2,...13000) is smaller than a threshold

(5000) from another dummy

gen memberh=(id<=sum(member))

But it doesn't work for some reason, it seems sum(member) is always 1, but why?

Recall that generate's sum function is a RUNNING sum, not the total of member. You want egen sum to generate a variable that is a constant across obs. Using auto,

g junk = (price < sum(price))

will be zero in the first obs and 1 thereafter.

But rather than creating a new variable, why not just

summarize member,meanonly

g memberh = (id < =r(sum))

Kit Baum, Boston College Economics

http://ideas.repec.org/e/pba1.html

*

* 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:
**st: sum** - Next by Date:
**Re: st: Cramer's V test** - Previous by thread:
**st: sum** - Next by thread:
**st: Cramer's V test** - Index(es):

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