You can use BY group processing to do most of it.
data want;
set have;
by keydate location conditiona conditionb conditionc NOTSORTED;
first = first.conditionc;
last = last.conditionc;
run;
You seem to want to clear the FIRST and LAST flags when at least one of the conditions are not met.
data want;
set have;
by keydate location conditiona conditionb conditionc NOTSORTED.
first = first.conditionc and 3=count('Yes',cats(conditiona,conditionb,conditionc));
last = last.conditionc and 3=count('Yes',cats(conditiona,conditionb,conditionc));
run;
But it might be better to make a separate flag variable to indicate whether or not the condition was met.
data want;
set have;
by keydate location conditiona conditionb conditionc NOTSORTED;
all_yes = 3=count('Yes',cats(conditiona,conditionb,conditionc));
first = first.conditionc ;
last = last.conditionc ;
run;
PS Do not use spaces in your variable names. It makes the code impossible to read and type.
... View more