Ciao, Here is a replication example in Stata. Here is data I have:
clear
Here is data I hope to get to:
Basically my aim is to take the first row for each id of a event equal to 1. If an id has no event for any time then I want to report the last time of the report.
clear
Code:
* Input data input float id str7 event time id event time 1 "." 10 1 "." 20 1 "1" 30 1 "0" 40 1 "." 50 2 "0" 10 2 "0" 20 2 "0" 30 2 "0" 40 2 "0" 50 3 "1" 10 3 "1" 20 3 "0" 30 3 "." 40 3 "." 50 4 "." 10 4 "." 20 4 "." 30 4 "." 40 4 "." 50 5 "1" 10 5 "1" 20 5 "1" 30 5 "1" 40 5 "1" 50 end
Code:
* Input data input float id str7 event time id1 event1 time1 1 1 30 2 0 50 3 1 10 4 . 50 5 1 10 end
Comment