What I expect to end up with is a data set as follows: ONE TWO COUNT LB UB 0 0 30 0 30 1 0 541 31 572 2 0 1525 573 2098 3 0 5 2099 2104 0 1 3 0 3 1 1 229 4 331 2 1 642 332 974 3 1 3 975 978 I was under the impression that the lines were sent in sequentially - i.e. SAS would do line 1, then Line2 , then Line3, etc. So, on my first iteration, LAG(UB) returns missing (as UB is all missing). But ONE==0 so therefore LB=0, then UB=LB(0) +count = 30 (which is what I get. On the second iteration, LB=LAG(UB)=30, and UB is then 31+541 = 572. And so on. And on all the other interations it will return the missing value pushed down from the LAG() call on the previous iteration. So LB will be set to missing. I guess that this is where the issue is. Why is it that LAG is not updating to the last value but keeping the missing values, even though the value of UB is changed?
... View more