In a compare with id, how can I output only the difference and the new records but not the old records no more present?
Example, suppose I have two tables:
mybase:
key other 1 Ann 3 Ann 4 Charlie 5 Emily and mycompare:
key other 2 Bill 3 Charlie 4 Charlie running:
proc compare data=mybase compare=mycompare outnoequal outdif out=myoutput listvar outcomp outbase method = absolute criterion = 0.0001 ; id key; run; I get a table "myoutput" like this:
type obs key other base 1 1 Ann compare 1 2 Bill base 2 3 Ann compare 2 3 Charlie dif 2 3 XXXXXXX base 4 5 Emily I would like to have this:
type obs key other compare 1 2 Bill base 2 3 Ann compare 2 3 Charlie dif 2 3 XXXXXXX 21 Answer
This works for your example. I think you want to output records that are not matched in base and any records that match and have differences.
data mybase; input key other $; cards; 1 Ann 3 Ann 4 Charlie 5 Emily ;;;; data mycompare; input key other $; cards; 2 Bill 3 Charlie 4 Charlie ;;;; proc compare data=mybase compare=mycompare outnoequal outdif out=myoutput listvar outcomp outbase method = absolute criterion = 0.0001 ; id key; run; proc print; run; data test; set myoutput; by key; if (first.key and last.key) and _type_ eq 'BASE' then delete; run; proc print; run; Obs _TYPE_ _OBS_ key other 1 COMPARE 1 2 Bill 2 BASE 2 3 Ann 3 COMPARE 2 3 Charlie 4 DIF 1 3 XXXXXXX. 1