Hello all
I am trying to find out the length of wait for each individual for a service given we know the average length of wait in a queue. I hope the example data will make it clear what I am trying to find out.
Code:
. version
version 13.1
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(start_time los_in_queue end_time)
4 2 .
. 5 .
. 6 .
. 7 .
. 8 .
end

I want the data to look like:
obs. start_time los_in_queue end_time
1 4 2 6
2 6 5 11
3 11 6 17
4 17 7 24
5 24 8 32

Basically, I want to retain the end_time of the first observation as a start_time for the second observation an so on.

My attempt overrides all previous values by the last value. Thanks in advance for pointing out where I went wrong.
Code:
. local N = _N
. local counter=1
. forvalues i = 1/`N' {
  2.      replace end_time = start_time[`i']+los_in_queue[`i']
  3.                 list start_time-end_time
  4.                 local i=`i'+1
  5.                 replace start_time = end_time[`i'-`counter']
  6.                 }
(5 real changes made)

. clist

          start_time     los_in_queue         end_time
  1.              32                2               32
  2.              32                5               32
  3.              32                6               32
  4.              32                7               32
  5.              32                8               32