Hi,

Im working with a dataset that contains 120 funds (id=1,120) and I have constructed two periods (period1 and period2). I now want to create a new variable that counts how many observations I have in each period.
See below for dataex.
In this case I would like the new variable obs_p1 to take the value 7 and the new variable obs_p1 to take the value 5.

Any suggestions about the code I need?
Thanks!

----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input float
(id period1 period2)
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 0 1
1 0 1
1 0 1
1 0 1
1 0 1