1
votes

I have two datasets where one is a subset of the larger one. What I want to do is to create a new dataset which is the complement of the smaller dataset. Is there a way to do this in SAS?

The image shows a snapshot of my data set

The smaller dataset is of specific perpetrators (In particular, perpetrator 2, 14 ,15 19) I now want a dataset which excludes these individuals

2
SQL joins are another option. If you look at the SQL join diagram, you want a right join i.imgur.com/1m55Wqo.jpgReeza

2 Answers

0
votes

You can do this using a merge, e.g.

data want;
  merge large_dataset
              subset(in=subset);
  by id;
  if not(subset);
run;
0
votes

Using SQL and "not in"

proc sql;
create table_want as
select distinct *
from violence
where perpetratorID not in (2, 14 ,15, 19)
quit;

if perpetratorID is not numeric, then ("2", "14" ,"15", "19")