OK, I've been trying to figure this out for the past several hours
so I am going to turn to the experts. If you can help point me
in the right direction, that would be a good start.
I have four columns of data, the first two are lengths of time
the third is a clock-like timer. The last column shows
what I am trying to duplicate with logic.
I need to keep track of the periods of time (timegroup variable)
when both lengths are not zero. For instance, after the first
three observations, the next four observations would have the
timegroup value of 1, then the next two observations have zero
values for both lengths so skip these. Then the next three obs
would have the timegroup value of 2.
The kicker is that when the third column variable, clockcount,
resets to 1, I need my timegroup values to restart at 1. So I've
been trying to use do while and do until loops with lag() but
have had no success.
I tried thinking about what I want to do in plain english and
came up with this ...
SET TIMEGROUP = 0
DO THIS WHILE CLOCKCOUNT NE 1
IF (LENGTH1+LENGTH2) gt 0 AND LAG1(TIMEGROUP) eq 0
THEN TIMEGROUP + 1
KEEP TIMEGROUP VALUE UNTIL
LENGTH1+LENGTH2 eq 0 AND LAG1(TIMEGROUP) gt 0
RETURN TO TOP
Any tips or suggestions? Thanks very much for your time.
INFILE DATALINES DELIMITER=',';
INPUT length1 length2 clockcount checknum;
PROC PRINT DATA = timetest;