BookmarkSubscribeRSS Feed
sam369
Obsidian | Level 7


Hi Community,

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

             MAXPRINT=300

             ;

  id usubjid;

run;

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

Thanks

Sam

1 REPLY 1
sassharp
Calcite | Level 5

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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1104 views
  • 0 likes
  • 2 in conversation