Dear Statalist,

How can I compute a new variable with the sum of observations per year and company: I want to find a way to aggregrate all distinct patents in a sample of n=1000000 approx to the year and firm, such that firm A has number of patents B in year Y and number of patents C in year Z, and so forth.

In this case, the number 9 under 'totaloutput' is the only number I want to keep because the data tells me there are 9 patents created by firm 3D SYS INC in 1996. from this data i only want to know the total amount of patents a firm has produced in a given year. this is only a sample of the total dataset.

year company id_name permno_adj totaloutput
1996 3 D SYS INC 9 78664 1
1996 3 D SYS INC 9 78664 2
1996 3 D SYS INC 9 78664 3
1996 3 D SYS INC 9 78664 4
1996 3 D SYS INC 9 78664 5
1996 3 D SYS INC 9 78664 6
1996 3 D SYS INC 9 78664 7
1996 3 D SYS INC 9 78664 8
1996 3 D SYS INC 9 78664 9
1996 3COM CORP 11 76129 1
1996 3COM CORP 11 76129 2
1996 3COM CORP 11 76129 3
1996 3COM CORP 11 76129 4
1996 3COM CORP 11 76129 5
1996 3COM CORP 11 76129 6
1996 3COM CORP 11 76129 7
1996 3COM CORP 11 76129 8
1996 3COM CORP 11 76129 9
1996 3COM CORP 11 76129 10
1996 3COM CORP 11 76129 11
1996 3COM CORP 11 76129 12
1996 3COM CORP 11 76129 13
1996 3COM CORP 11 76129 14
1996 3COM CORP 11 76129 15
1996 3COM CORP 11 76129 16
1996 3COM CORP 11 76129 17
1996 3COM CORP 11 76129 18
1996 3COM CORP 11 76129 19
1996 3COM CORP 11 76129 20
1996 3COM CORP 11 76129 21
1996 3D LAB INC LTD 12 84266 1
1996 3D LAB INC LTD 12 84266 2
1996 3D LAB INC LTD 12 84266 3


I'd very much appreciate your help. thank you in advance!