I need to do a quick ad-hoc operation in user written code. The program needs to locate row 2, store its variable "from_dttm" minus 1 second into the new variable "newdate", then locate row 4 and put "newdate" into "to_dttm".
I know I'm not handling the date values correctly in the code below, and would appreciate any advice on how to resolve this. Thank you.
data &_output;
set work.replace;
format newdate NLDATM21.;
if _n_ = 2 then do;
newdate = from_dttm-1;
end;
if _n_ = 4 then do;
to_dttm = newdate;
end;
run;