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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: