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);
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: