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

st: var gen based on history


From   "Webb.Bayard" <[email protected]>
To   "'StataList'" <[email protected]>
Subject   st: var gen based on history
Date   Fri, 11 Jul 2003 17:22:41 -0700

Hi all,

I have variables Category, Date and Amount and I need to generate two new
variables described as follows.

minAmount = smallest Amount in Category as of Date 
maxAmount = largest Amount in Category as of Date 


Example:
Category		Date		Amount	min	max
1			1/1/2001	50		50	50
2			1/1/2001	100		100	100
1			1/2/2001	52		50	52
2			1/2/2001	98		98	100
1			1/3/2001	47		47	52
2			1/3/2001	105		98	105
1			1/4/2001	55		47	55
2			1/4/2001	93		93	105

I've looked, but I can't come up with the right gen or egen commands and
I've not yet tackled programming. I'm hoping someone can spot some tricky
way of accomplishing this.

Any help would be appreciated.

Bayard
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index