Statalist The Stata Listserver


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

RE: st: Generating mean by two groups


From   "chintal desai" <[email protected]>
To   [email protected]
Subject   RE: st: Generating mean by two groups
Date   Wed, 10 Jan 2007 22:19:07 -0500

You can try using collapse command of stata.

collapse (mean) P, by (L D)




From: "Z. Aloha" <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: st: Generating mean by two groups
Date: Tue, 9 Jan 2007 18:32:30 -0500

Hi,
How can I generate a mean by two groups. That is I have different
location allocations (L)  and different dates (D), and I would like to
generate a new variable (M) that contains the mean of the price (P)
within each location on each date. An example is listed below:
P       L       D      M
1       A       1     1.5
2       A       1     1.5
3       B       1      3
3       B       1      3
5       A       2      5.5
6       A       2      5.5
3       B       2       5
7       B       2       5
2       A       3       3.5
5       A       3       3.5
4       B       3       6
8       B       3       6
12      A       4      8
4       A       4       8
6       B       4       4
2       B       4       4


Thanks for your help
*
*   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/
_________________________________________________________________
Find sales, coupons, and free shipping, all in one place! �MSN Shopping Sales & Deals http://shopping.msn.com/content/shp/?ctid=198,ptnrid=176,ptnrdata=200639

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