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 on April 23, and its replacement, statalist.org is already up and running.


[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 <nfukugawa@gmail.com>
To   statalist@hsphsun2.harvard.edu
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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index