Your description of your objective is very sparse. But you can do "inter" obs comparsons by reading through a single id group, in a DO UNTIL LAST.ID do-group. Something like:
data have;
input ID $ Product $ Acc $ Type $ Value1 Value2 Value3;
datalines;
1 C 3 Red 3 3 1
1 A 1 Blue 2 1 0
2 D 2 Orange 0 2 .
2 B 4 Yellow 4 4 2
3 B 3 Blue 5 3 .
3 C 5 Orange 1 1 .
;
data want (keep=ID ERR);
do until (last.id);
set have;
by id;
if catx(',',product,acc)='B,4' and value1>0 then _condition_a1=1; else
if catx(',',product,acc)='D,2' and value1=0 then _condition_a2=1;
length type_list $400;
type_list=catx(',',type_list,type);
end;
length ERR $10;
if n(of _condition_a:)=2 then do;
err='E3';
output;
end;
if findw(type_list,'Blue')>0 and findw(type_list,'Orange')>0 then do;
err='Type 2 error';
output;
end;
run;
... View more