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]
st: how to create a variable representing proportion and average for each id
From
fukugawa_nobuya <[email protected]>
To
[email protected]
Subject
st: how to create a variable representing proportion and average for each id
Date
Mon, 26 Sep 2011 11:10:38 +0900
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/