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
Which lagged variable to include? (Wald Tests)Hi Statalisters, I am currently running a FE regression for a 2-period panel data set in China. I h…
Unconditional Quantile Regression-Counterfactual decomposition analysisDear STATA pros, For my research, using the India NSS data, I'm observing the gap in consumption of…
Clustered standard errorsHi, I ran fixed effects regression on my panel data and found that heteroskedasticity and autocorre…
Relevant test (t-test/z-test etc.)Dear All, I want to ask you what is the most appropriate test for testing significance in differenc…
Mergining in a loopHello, I'm trying to merge 3 tempfiles named: part1, part2, part3. I used the following code: use …
Subscribe to:
Post Comments (Atom)
0 Response to Count observations in periods
Post a Comment