One possibility is to use a MODIFY statement:
data run_table;
snpst_dt="01NOV2018"d;
run_ts=datetime();
format run_ts datetime22.3 snpst_dt yymmdd10.;
run_id=1;
run;
%let dt="&sysdate"d;
data run_table;
modify run_table nobs=nobs point=nobs;
if snpst_dt=&dt then
run_id+1;
else
run_id=1;
snpst_dt=&dt;
run_ts=datetime();
output;
stop;
run;
You should just make sure to keep your run_table is sorted correctly, so that the newest OBS is last (if you sort it by anything other than run_ts, this will not work). This way, you do not have to append the data afterwards.
But if you want to occasionally add stuff from previous snapshot dates, the smart thing is to use an index, e.g.:
data run_table(index=(snpst_dt));
snpst_dt="01NOV2018"d;
run_ts=datetime();
format run_ts datetime22.3 snpst_dt yymmdd10.;
run_id=1;
run;
%let dt="&sysdate"d;
data run_table;
snpst_dt=&dt;
do run_id=1 by 1 until(_iorc_);
modify run_table key=snpst_dt;
end;
_error_=0;
run_ts=datetime();
output;
stop;
run;
... View more