Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: averageifs function in Stata


From   Lisa Wang <lhwang0925@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: averageifs function in Stata
Date   Tue, 24 Jul 2012 13:18:07 +1000

Dear Stata-listers,

I am wondering how I can do something similar to an =averageifs
function from Excel in Stata. I know how to do this in Excel but would
like to learn this in Stata. I am new to Stata, so still often think
about how this would  be done in Excel.

I have variables id1 (string) and d_rates (values).


For example:
obs id1 d_rates
1  A56 100
2 A56 89
3 A56 30
4 A56 78
5 A9876 42
6 A9876 86
7 B173 100
8 B173 68
9 B173 47

etc...etc..

I would like some commands in Stata that produces a new variable or
some table where it can tell me what the average d_rates of person
A56, A9876, B173...etc. where there might be a different number of
observations for each id1 (eg. A56 has 4 obs and A9876 has only 2
obs)...

Is this possible?

Thank you for your consideration and time.

Regards,
Lisa
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index