@Xinxin wrote:
There are cases where control is no, no, yes, no, no, yes -- these are 2 episodes, I haven't figured programming for that either.
Provide an example data step that illustrates some example data with this case.
The data is likely going to be amenable to use of BY processing with the NOTSORTED option.
The following code allows identifying first and last of groups of values. This may give a starting point for dealing with the more complex cases.
data example;
input id desc $;
datalines;
1 LABE
1 LABE
1 XXX
1 XXX
1 LABE
1 LABE
1 XXX
1 XXX
2 LABE
2 XXX
2 XXX
;
RUN;
data byexample;
set example;
by notsorted id desc;
startid=first.id;
endid =last.id;
startdesc= first.desc;
enddesc = last.desc;
run;
The 1 values for started, startdesc and enddesc indicate "true" for being first or last, 0 are false.
Note that single value group (only one id desc before the desc changes) has the first and last true for desc as shown by the first record for Id 2 above.
... View more