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;
to keep the values of newdate across "rows" you need to add a retain statement.
retain newdate . ;
If you need to do this to many records you'll probably need a different approach.
to keep the values of newdate across "rows" you need to add a retain statement.
retain newdate . ;
If you need to do this to many records you'll probably need a different approach.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.