Hello,
I am currently preparing my data for a CSDID analysis.
When you look at my dataset (below), you can see that each 'ID number' has 12 months.
It is necessary to create a variable that shows the month in which the variable 'value' was equal to or larger then 10.000 for the first time for each 'ID'.
For example, all observations with 'ID 1' should have 2 as their 'firsttreated' observation.
Even though the value also goes over 10.000 in the third month. The observation of 'firsttreated' should still be 2 for all observations of 'ID 1'.
This process, of always finding the first month of an 'ID' in which value equaled or exceeded 10.000 should then be repeated for each 'ID'.
If anyone knows any variable transformation that could do this for all 'ID's' and observations in my dataset, I would be very grateful!
Thank you in advance and kind regards,
Glen
I am currently preparing my data for a CSDID analysis.
When you look at my dataset (below), you can see that each 'ID number' has 12 months.
It is necessary to create a variable that shows the month in which the variable 'value' was equal to or larger then 10.000 for the first time for each 'ID'.
For example, all observations with 'ID 1' should have 2 as their 'firsttreated' observation.
Even though the value also goes over 10.000 in the third month. The observation of 'firsttreated' should still be 2 for all observations of 'ID 1'.
This process, of always finding the first month of an 'ID' in which value equaled or exceeded 10.000 should then be repeated for each 'ID'.
If anyone knows any variable transformation that could do this for all 'ID's' and observations in my dataset, I would be very grateful!
Thank you in advance and kind regards,
Glen
Code:
input float(ID month) double(value property violent) float(prize firsttreated) 1 1 9000 2 3 9 0 1 2 11000 2 3 11 0 1 3 11000 2 3 11 0 1 4 9000 0 4 9 0 1 5 8000 2 3 8 0 1 6 9000 0 3 9 0 1 7 15000 0 13 15 0 1 8 10500 0 0 10.5 0 1 9 8000 0 2 8 0 1 10 12000 2 5 12 0 1 11 7300 0 5 7.3 0 1 12 10000 4 2 10 0 2 1 5000 0 4 5 0 2 2 7000 3 1 7 0 2 3 20000 7 4 20 0 2 4 3000 3 0 3 0 2 5 6800 0 0 6.8 0 2 6 5000 0 1 5 0 2 7 2000 0 2 2 0 2 8 6000 1 2 6 0 2 9 4000 0 1 4 0 2 10 7000 0 2 7 0 2 11 7600 0 3 7.6 0 2 12 4000 1 1 4 0 3 1 13000 7 3 13 0 3 2 6000 1 1 6 0 3 3 14300 7 5 14.3 0 3 4 6000 4 0 6 0 3 5 15000 5 5 15 0 3 6 24000 9 2 24 0 3 7 10000 5 0 10 0 3 8 11500 12 0 11.5 0 3 9 16000 5 3 16 0 3 10 18800 12 4 18.8 0 3 11 19000 11 3 19 0 3 12 7000 1 4 7 0 4 1 4000 0 0 4 0 4 2 7000 1 5 7 0 4 3 8300 2 2 8.3 0 4 4 2000 0 2 2 0 4 5 5500 0 1 5.5 0 4 6 7000 0 3 7 0 4 7 4700 0 0 4.7 0 4 8 11500 0 0 11.5 0 4 9 6000 1 4 6 0 4 10 6700 0 0 6.7 0 4 11 10300 0 0 10.3 0 4 12 7000 0 1 7 0 5 1 6000 0 0 6 0 5 2 5000 0 0 5 0 5 3 8300 3 4 8.3 0 5 4 9000 1 4 9 0 5 5 17000 1 9 17 0 5 6 15000 0 7 15 0 5 7 6600 0 2 6.6 0 5 8 8500 1 1 8.5 0 5 9 5000 0 1 5 0 5 10 8900 3 2 8.9 0 5 11 8000 3 2 8 0 5 12 14000 0 6 14 0 6 1 3000 1 0 3 0 6 2 2000 2 0 2 0 6 3 5000 1 2 5 0 6 4 4000 1 0 4 0 6 5 6300 0 1 6.3 0 6 6 7000 2 2 7 0 6 7 5300 0 0 5.3 0 6 8 3000 0 0 3 0 6 9 7000 2 3 7 0 6 10 4000 1 3 4 0 6 11 5300 0 0 5.3 0 6 12 7000 1 4 7 0 7 1 12000 2 4 12 0 7 2 14000 2 5 14 0 7 3 18600 2 6 18.6 0 7 4 7000 2 2 7 0 7 5 21300 0 6 21.3 0 7 6 21000 4 7 21 0 7 7 12300 3 6 12.3 0 7 8 6500 1 5 6.5 0 7 9 0 0 6 0 0 7 10 9300 3 5 9.3 0 7 11 11100 0 5 11.1 0 7 12 12000 2 7 12 0 8 1 4000 0 1 4 0 8 2 9000 2 5 9 0 8 3 4000 0 3 4 0 8 4 4000 0 3 4 0 8 5 5000 4 1 5 0 8 6 5000 4 1 5 0 8 7 2000 0 2 2 0 8 8 6500 1 4 6.5 0 8 9 11000 2 4 11 0 8 10 9800 2 1 9.8 0 8 11 7000 0 5 7 0 8 12 4000 0 2 4 0 9 1 3000 0 1 3 0 9 2 4000 1 0 4 0 9 3 6600 0 3 6.6 0 9 4 4000 4 0 4 0 end
Comment