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: how to create a variable representing proportion and average for each id
From
Ulrich Kohler <[email protected]>
To
[email protected]
Subject
Re: st: how to create a variable representing proportion and average for each id
Date
Mon, 26 Sep 2011 08:59:58 +0200
. egen xpro = mean(x), by(id)
. egen yavg = mean(y), by(id)
Uli
Am Montag, den 26.09.2011, 11:10 +0900 schrieb fukugawa_nobuya:
> dear statalisters,
> is it possible to create a new variable like "xpro" shown below, which
> represents each id's proportion of x==1?
> how about "yavg" shown below, which represents each id's average of y?
>
> id x xpro y yavg
> 1 1 .667 2 2
> 1 0 .667 3 2
> 1 1 .667 1 2
> 2 1 .5 2 1
> 2 0 .5 0 1
> 3 0 0 0 0
>
> thank you in advance.
>
> --------------------
> FUKUGAWA Nobuya, Ph.D.
> Associate Professor
> Graduate School of Engineering
> Tohoku University
> http://sites.google.com/site/nfukugawa/
>
> *
> * 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/