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
Drop values in columns without using the drop duplicates commandDear Stata community, I am new to Stata programming and currently conducting an event study on ad h…
"Variables do not uniquely identify the observations" error when mergingHi everyone. I am trying to merge two datasets constructed from German SOEP data. The datasets have …
MC Simulation: How to return regression results for multiple regressions?Hello, I am attempting to return coefficient results from multiple regressions using a simulation. …
Generating variable that measures the difference between the last and first yearDear Statalisters, I am trying to generate a variable that measures how much the CPIA index for ins…
Simple linear regression: difference of results in Stata when compared to Excel (why?)I performed a simple linear regression in Stata and in Excel by relating the number of hotel arrival…
Subscribe to:
Post Comments (Atom)
0 Response to Count observations in periods
Post a Comment