I added a join to the solution above: data one; infile cards dsd; input SINo ID$ status_number$ Type$; cards; 1,123,45678,sales 2,123,34567,cost 3,123,78795,sales 4,123,98765,invoice 5,123,12345,sales 6,234,56872,sales 7,234,76549,cost 8,234,88887,sales 9,234,66666,invoice 10,234,11111,invoice ; run; data two; infile cards dsd; input SINo ID$ status_number$ Type$ percent; cards; 1,123,45678,sales,0 2,123,34567,cost,100 3,123,78795,sales,100 4,123,98765,invoice,100 5,123,12345,sales,100 6,234,56872,sales,100 7,234,76549,cost,0 8,234,88887,sales,0 9,234,66666,invoice,100 10,234,11111,invoice,100 ; run; proc sql; create table output as select a.sino,a.id,a.status_number,a.type,b.percent, case when count(*) < 3 then 'Correct' else 'Error' end as Output from one a left join two b on a.id = b.id and a.status_number = b.status_number where a.type = 'sales' group by a.id order by a.sino,a.id;
... View more