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
Related Posts with Count observations in periods
Ologit, Paralell Regression Assumption and weightsHi, it's the first time i write here, hope the question is not too emantary, I'm trying to replicat…
Moving cumulative sum over 10-year periodDear Statalist Community, I am currently struggling with a data transformation task and was wonderi…
Regression for state-wide daily data with fixed population percentage within statesHello, So I have data set up as such (sample data that I just made up): Code: * Example generated b…
Moving cumulative sum over 10-year periodDear Statalist Community, I am currently struggling with a data transformation task and was wonderi…
Reshape data from long to wide format using the rolling windowsDear all, I am desperately looking for your help. I am trying to reshape my data from long to wide …
Subscribe to:
Post Comments (Atom)
0 Response to Count observations in periods
Post a Comment