One possible interpretation of what you appear to be asking for is to calculate a running maximum values of COL2. With the added feature of starting with the third value
data want ;
if _n_=1 then set have(firstobs=3 obs=3 rename=(col2=running_max));
set have;
running_max=max(running_max,col2);
run;
or possibly the value where col1=3.
data want ;
if _n_=1 then do;
set have(obs=1 rename=(col2=running_max));
where col1=3;
end;
set have;
running_max=max(running_max,col2);
run;
Result
running_
Obs Col1 max Col2
1 1 3 1
2 2 3 2
3 3 3 3
4 4 4 4
5 5 4 3
6 6 6 6
7 7 6 1
8 8 6 3
... View more
The values in Col1 for applying a floor is set to by the user, and the floored value to Col2 is determined by the the corresponding Col2 for the Col1 value.
... View more
Hi Both, Many thanks for your quick response. Col4 simply counts the occurrence of values in Col1 , but will recount when Col3 is flagged. I will study the BY statement, which is perhaps unique to SAS, and try to figure out myself using your codes provided.
... View more