Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Calculating cumulative value over several observations


From   "Clyde Schechter" <[email protected]>
To   [email protected]
Subject   RE: st: Calculating cumulative value over several observations
Date   Sat, 11 Dec 2010 10:47:13 -0800

I think this will get you what you want:

levelsof buyer, local(buyers)
levelsof seller, local(sellers)
local participants: list buyers | sellers
sort market period observation

foreach p of local participants {
	by market period (observation): gen M`p' = sum(price*(seller==`p')) -
sum(price*(buyer==`p'))
	by market period (observation): gen A`p' = sum(buyer == `p') - sum(seller
== `p')
}

Note:  If your buyers and sellers constitute the integers between 1 and P
for some P, then you don't need to do the -levelsof- commands and you can
replace the foreach loop with a forvalues p = 1/P loop.

By the way, just out of curiosity, if everybody starts out with no money
and no apples, how do they make these trades?

Clyde Schechter, MA MD
Associate Professor of Family & Social Medicine

Please note new e-mail address: [email protected]

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index