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

From |
Kit Baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: sum |

Date |
Mon, 31 Oct 2005 12:19:38 -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: quarterly data** - Next by Date:
**st: sum** - Previous by thread:
**Re: st: sum** - Next by thread:
**st: sum** - Index(es):

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