<>
You would probably be better -reshape-ing the data to long form. See
******
help reshape
******
under "Remarks". Then you can indeed apply -bysort- to your problem...
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von HSIUTZU CHANG
Gesendet: Mittwoch, 29. Juli 2009 16:03
An: [email protected]
Betreff: st: calculate the average by subgroup for a panel dataset
---------- Forwarded message ----------
From: HSIUTZU CHANG <[email protected]>
Date: Wed, Jul 29, 2009 at 2:48 PM
Subject: calculate the average by subgroup for a panel dataset
To: [email protected]
Dear Stata users:
How can I calculate the average of serveral variables by the subgroup
of another variable?
I have a panel dataset of property sale price information and I need
to calculate the average of the sale prices (s1, s2, s3) by zipcode
area (zip).
Since there are missing values in my dataset, I have tried using a
command suggested from an eariler thread
http://www.stata.com/statalist/archive/2007-02/msg00143.html
egen ave= rmean(s1-s3)
but this command only calculate the average of s1-s3 for each record.
In order to calculate the average of s1-s3 by zip, I tried:
bysort zip: egen ave2= rmean(s1-s3)
I got an error messaging saying
" egen ... rowmean() may not be combined with by
r(190)"
I am a beginer to STATA, so any suggestions will be welcome!
Thank you
Betty
*
* 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/
*
* 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/