data work.profit work.errors; set ia.dnunder; set ia.sale2000(keep = RouteID FlightID Date Rev1st RevBusiness RevEcon RevCargo) key = FlightDate/unique; if _IORC_ = 0 then do; Profit = sum(Rev1st, RevBusiness, RevEcon, RevCargo, - Expenses); output work.profit; end; else do; _error_ = 0; output work.errors; end; run; proc print data = work.profit (firstobs = 895); title 'Combining Data Sets and Eliminating Non-matches'; run; proc print data = work.errors; title 'Errors data'; run;