10-17-2012 04:11 PM
i have a situation ,like i am comparing the pervious database to new database.
For exapmple . AE dataset. we collected Ae dataset in 2011 and 2012. I am comparing both datasets.
i need to show the newly added records. difference between old and new. I am using this code
proc compare base = ae
compare = aenew
out = difs
OUTNOEQUAL LISTEQUALVAR LISTCOMPVAR LISTBASEVAR
in new data(2012) one or more usubjid have extra records. How to display new reocord and how to display the variable having different values
10-18-2012 05:28 PM
https://communities.sas.com/thread/33633 I am sure this would help. Proc compare compares each column from table 1 to table 2 in a row. For example if there is a rundate in table1 and rundate in table2 need not be same even you started to run the code same time to get table1 and table2. For comparing two tables I am sure this is going to be usefulcode. /* first outer join table1 and table2*/ Proc SQL; Create table table1andtable2outerjoin as Select a.id as id_1, a.name as name_1, b.id as id_2, b.name as name_2 From table1 as a Full Outer Join table2 as b on a.id = b.id and a.name=b.name; Quit; /*to see rows only in table2 not in table1 you can add more columns for comparison*/ Data tablenew; Source = 'two'; Length Source $5; Set table1andtable2outerjoin ; if missing(id_1) and missing(name_1) then output; Format Source $5.; Informat Source $5.; run; /*to see rows only in table1not in table2 you can add more columns for comparison*/ Data tableold; Source = 'one'; Length Source $5; Set table1andtable2outerjoin; if missing(id_2) and missing(name_2) then output; Format Source $5.; Informat Source $5.; run; /*to see rows side by side*/ Data tablenewold; Set tablenew tableold; run;