Yes you understood me well, and you answered my condition 2. condition 1 was not to display the observations below a certain number n. (In my case n = 3). So I added a proc sql to count the number of observations generated by your code for each id in each exercise and I think it works fine. Or do you have another proposal? data temp;
set have;
flag=not missing(records);
run;
data temp1;
set temp;
by id flag notsorted;
group+first.flag;
run;
data want0;
set temp1(where=(flag=1));
by id group;
if first.id then count=0;
count+first.group;
if count=1;
run;
proc sql;
create table want1 as
select ID,exercice, date_of_check,records , count(distinct records ) as counter
from want0
group by Id, exercice;
quit;
data want;set want1;
if counter<2 then delete;
drop counter;
run;
... View more