@Astounding, I think you might have overlooked one tiny detail, that is for a dataset option, 'where' happens after 'rename', so it should be
if timedif < 0 then set have (keep=date where=(replacement_date > .) rename=(date=replacement_date));
@gnrslasher37, the following approach requires almost the same condition as the one provided by @Astounding, except you can have multiple populated 'date' value within the same day, and the only thing to determine if a new date starts is the current 'time' less than or equal to the last 'time'.
data have;
input Date Time :time5. Price;
format time time5.;
cards;
. 20:12 1440
20030223 23:57 1200
. 23:59 1150
. 00:01 1100
20030224 02:34 1400
;
data want;
do _n_=1 by 1 until (time >= _t);
set have;
set have(firstobs=2 rename=(time=_t)) have(obs=1 drop=_all_);
if not missing(date) then
_d=date;
end;
do _n=1 to _n_;
set have;
date=_d;
output;
end;
drop _:;
run;
... View more