Hi all. I am a bit confused about how to handle this situation:
I have an input table (table A) storing a list of Names, Surnames, IDs, Telephone numbers, Dates of birth and other personal data. This table is ran and updated every day, with new records appended.
From this table, I created another table (table B) containing only IDs and Telephone numbers from table A. This table is likewise updated every day.
What I need to do is to compare the newest version of table A with yesterday's version of table B, i.e. I need to extract the records that have been inserted in table A in the last run. How can I do this?
So where is the old table, anyway? It must exist somewhere in a permanent library.
Create the new tables in WORK, and then compare the WORK table with its counterpart in the permanent library. After that is done, copy the WORK tables to the permanent location.
Keep your tables sorted by ID. Then you can do;
data compare;
merge
a (in=a keep=id)
b (in=b keep=id)
;
by id;
if a and not b;
run;
before you update B.
Or, in SQL:
proc sql;
create table compare as
select a.id
from a
where a.id not in (select id from b)
;
quit;
So where is the old table, anyway? It must exist somewhere in a permanent library.
Create the new tables in WORK, and then compare the WORK table with its counterpart in the permanent library. After that is done, copy the WORK tables to the permanent location.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.