I have a dataset with nine different dates. Every time the job is launched, if the dataset already contains nine different dates, it deletes the least recent date, ensuring that there are always nine dates: %macro versioning(FLOW=,dt_rif=);
proc sql noprint;
select count(distinct data_rif) into : num_ver
from &FLOW
;
quit;
proc sql noprint;
select count(*) into : num_obs
from &FLOW
where data_rif=&dt_rif;
quit;
%if &num_ver = 9 && &num_obs=0 %then %do;
proc sql noprint;
select min(data_rif) into : data_rif_to_del
from &FLOW;
quit;
data &FLOW;
set &FLOW;
where data_rif ne &data_rif_to_del;
run;
%end;
%mend; The issue is that the number of historical dates is no longer fixed at 9; it can vary. For example, it could be 5 or 12. How can I modify the code to determine which dates (&data_rif_to_del) need to be deleted?
... View more