# Re: st: how to generate sum of distinct id1, by id2, in the lastn years

 From "Eric G. Wruck" To statalist@hsphsun2.harvard.edu Subject Re: st: how to generate sum of distinct id1, by id2, in the lastn years Date Tue, 18 Sep 2007 10:58:46 -0400

```Hi Pierre:

I started to work on this but then realized I don't understand your data & problem properly.  In 1972 we see that star author 1 wrote a paper w. joe 2 & wrote zero papers w. joe 3.  Presumably too star author 1 wrote zero papers w. joes 4 & 5, although there is no observation saying so.  So, I don't understand how in your desired output you expect to get stk_nbcoauth_it (what does this mean?) = 2 for 1972.  Also, 1975 only appears once in your data (3 papers written w. joe 2) but in your desired output, stk_nbcoauth_it = 2 -- please explain.  Lastly, you mention something about performing the summing over the last three years -- what does that mean here?

Later,

Eric

>Dear Statalisters,
>
>I have what I believe a simple programming question that I can't quite solve.
>I have a panel of dyads, where each member of the dyad is a coauthor.
>Each dyad is composed or a "superstar" and a "simple joe/jane."
>
>For instance:
>
>star_id		id		year		nbpapers
>---------------------------------------------------------
>1		2		1972		1
>1		2		1973		0
>1		2		1974		2
>1		2		1975		3
>1		2		1976		0
>1		2		1977		4
>1		3		1970		1
>1		3		1971		0
>1		3		1972		0
>1		3		1973		2
>1		4		1978		2
>1		4		1979		1
>1		5		1977		4
>1		5		1978		1
>1		5		1979		0
>1		5		1980		1
>1		5		1981		1
>
>So superstar #1 has 4 "simple joe collaborators" numbered 2,3,4, and 5.
>In each year, the data records how many publications exist for
>superstar i and simple joe/jane j.
>
>
>I would like to collapse this data at the superstar/year level and
>create a variable that records the sum of distinct "simple joes" in
>the last 3 years.
>In other words, I'd like to create the variable stk_nbcoauth_it that is:
>
>star_id	year	stk_nbcoauth_it
>---------------------------------
>1	1970	1
>1	1971	1
>1	1972	2
>1	1973	2
>1	1974	2
>1	1975	2
>1	1976	1
>1	1977	2
>1	1978	3
>1	1979	3
>1	1980	2
>1	1981	2
>
>I have fiddle with bysort star_id id (year), but without clear
>success. Could anyone help?
>
>Regards,
>
>Pierre
>
>
>
>--------------------------------------------------------------------
>Pierre Azoulay
>Assistant Professor of Strategy
>Massachusetts Institute of Technology
>Sloan School of Management
>50 Memorial Drive - E52-555
>Cambridge, MA 02142-1947
>
>Tel [Sloan]: (617) 258-9766
>Tel [NBER]: (617) 588-1464
>Fax: (617) 253-2660
>

--

===================================================

Eric G. Wruck
Econalytics
Columbus, OH  43209

ph:      614.231.5034
cell:    614.330.8846
eFax:    614.573.6639
eMail:   ewruck@econalytics.com
website: http://www.econalytics.com

====================================================
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```