Hi
I have two data sets, one of which is a sub-set of the other. What I would like to do is to create a third data set that contains the records that are not common to both data sets. Does anyone know of a clean way to do this?
Paul
If dataset B is a subset of dataset A then
proc sql;
create table A_minus_B as
select * from A
EXCEPT
select * from B;
quit;
selects rows from A which do not appear in B
PG
This statement would not work because it does not give an indicator of a column to match on? Even though the records are a sub-set, the columns are slightly different between the two.
Paul
This macro provides one way to do that
see also
Using the EXCEPT Operator in PROC SQL
and Generation Data Sets to Produce a Comparison Report
Stanley Fogleman,
I found an answer actually.
Paul
I would like to know what it is. Could you please share? - PG
Is it this last example from the page you cited.
(query1 except query2) union (query2 except query1)
proc sql; title 'A EXCLUSIVE UNION B'; (select * from sql.a except select * from sql.b) union (select * from sql.b except select * from sql.a);
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.