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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.