Hi there,
I am looking for a code that combine the rows when end_date = start_date for a certain ID when all the variables have same values. For example, in the table below, ID 1 has 4 rows and their variables x and y have the same values in each rows under ID 1. ID 1 has end_date=start_date in each of its row. In that case, ID 1 will be combined into one row that will show the very first start_date and very last end_date.
id start_date end_date x y
1 10 12 10 12
1 12 14 10 12
1 14 16 10 12
1 16 21 10 12
2 11 13 15 17
2 13 15 15 17
3 16 18 20 22
3 18 20 20 22
3 20 25 20 22
Result will look like this:
id start_date end_date x y
1 10 21 10 12
2 11 15 15 17
3 16 25 20 22
I am seeking for help to get the code.
Thank you.
Kind regards,
Rakib
Related Posts with Combine multiple rows into one when end_date = start_date
Error when use xtcsd (_variable merge already defined)Hi, I have a problem when I use xtcsd. After I run using xtreg depvar indepvar, fe , and then use "x…
Dummy Variable as Dependent Variable in a Panel RegressionGood Day Everyone! I am doing a panel regression on have a problem in running panel models in Stata…
Help with multilevel survival analysisI am currently conducting a study that follows patients over 30 days to see if they have an event. P…
-xtevent- Stata module to estimate and visualize linear panel event-study models now available on SSCIt's been a while since I posted anything to Statalist!!! Thanks to Kit Baum, -xtevent- is now avai…
Merge 2 datasets: individual and county level datasetsI need to merge two datasets. One has individual-level data and the other has county-level data. I…
Subscribe to:
Post Comments (Atom)
0 Response to Combine multiple rows into one when end_date = start_date
Post a Comment