Reputation: 7942
Is there a way in sas to create disjoint data sets using the SET
statement?
I have tried:
DATA OnlyFirst OnlySecond InBoth;
SET firstds(IN=A)
seconds(IN=B);
IF A AND NOT B THEN OUTPUT OnlyFirst;
IF B AND NOT A THEN OUTPUT OnlySecond;
IF A AND B THEN OUTPUT InBoth;
Run;
But this does not create disjoint sets.
Upvotes: 0
Views: 239
Reputation: 1807
That's not how the set
statement works. You should be able to use a merge
if you first make sure firstds and seconds are both sorted by a key variable (or variables) they both share. You'd then need to reference that shared variable in a by
statement.
DATA OnlyFirst OnlySecond InBoth;
merge firstds(IN=A)
seconds(IN=B);
by <something shared variable>;
IF A AND NOT B THEN OUTPUT OnlyFirst;
IF B AND NOT A THEN OUTPUT OnlySecond;
IF A AND B THEN OUTPUT InBoth;
Run;
Upvotes: 1