Hi experts,
I have a dataset which have columns Event and Time. I need to create columns Group and Cumulative. What I need to measure is the duration of the Event 'Event1_Stop' until an 'Event1_Start' appears. Last group should sum the time meaning that the stop is ongoing and no start for the event has entered.
My data sample is:
data have; length Event $15; input Event $ Time; datalines; Event3_Start 0.2 Event2_Start 0.4 Event2_End 0.2 Event1_Stop 0.2 Event3_Start 0 Event4_Start 0.5 Event3_Stop 0.2 Event1_Start 0 Event4_Stop 0 Event4_Stop 0 Event1_Stop 0.3 Event3_Start 0.3 Event1_Start 0 Event3_Start 0.4 Event3_Stop 0 Event1_Stop 0.2 Event3_Start 0.2 Event2_Start 0.4 run;
The result dataset that I need to obtain is:
data have; length Event $15; input Event $ Time Group Cumulative; datalines; Event3_Start 0.2 0 0 Event2_Start 0.4 0 0 Event2_End 0.2 0 0 Event1_Stop 0.2 1 0.9 Event3_Start 0 1 0 Event4_Start 0.5 1 0 Event3_Stop 0.2 1 0 Event1_Start 0 0 0 Event4_Stop 0 0 0 Event4_Stop 0 0 0 Event1_Stop 0.3 2 0.6 Event3_Start 0.3 2 0 Event1_Start 0 0 0 Event3_Start 0.4 0 0 Event3_Stop 0 0 0 Event1_Stop 0.2 3 0.8 Event3_Start 0.2 3 0 Event2_Start 0.4 3 0 run;
Thanks for your suggestions.
Regards.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.