Hi:
You are on the right track for interleaving, however, your IN= variable and your subsetting IF are limiting the new dataset to only those observations that come from selena.cps65plus08a -- which doesn't sound like what you want.
You might need to put an IN= on the secondary dataset as well, and then tailor your IF statement accordingly. If I understand you correctly, you want EVERY obs from the first dataset, but only SOME obs from the second dataset??
Consider this data (Name, Present_type, Amtspend are my variables. I'm also making a variable called FROMFILE so that the final output shows which file contributed the interleaved observation):
[pre]
data one;
length name present_type $12;
infile datalines;
input name $ present_type $ amtspend;
fromfile = 'one';
return;
datalines;
alan anniversary 15
alan birthday 10
carl anniversary 15
edna birthday 20
;
run;
data two;
length name present_type $12;
infile datalines;
input name $ present_type $ amtspend;
fromfile = 'two';
return;
datalines;
alan christmas 25
bob anniversary 10
bob birthday 15
carl birthday 10
edna christmas 15
;
run;
[/pre]
For this data, I want ALL the obs from dataset ONE and everybody from dataset TWO except poor Carl -- he only gets an anniversary present. So this is the output I want:
[pre]
present_
Obs name type amtspend fromfile
1 alan anniversary 15 one
2 alan birthday 10 one
3 alan christmas 25 two
4 bob anniversary 10 two
5 bob birthday 15 two
6 carl anniversary 15 one
7 edna birthday 20 one
8 edna christmas 15 two
[/pre]
Created by THIS program:
[pre]
data three;
set one(in=inone)
two(in=intwo);
by name;
if inone or
(intwo and name ne 'carl') then output;
run;
ods listing;
proc print data=three;
title 'three';
run;
title;
[/pre]
If you have more complex conditions, then you'll have to code for those as well. This was just a simple test. But it should give you an idea of how interleaving works. Remember that the BY in interleaving performs differently than the BY in merging.
To learn more about the interleaving process, I recommend this site,
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001318366.htm
which has a section entitled: Understanding the Interleaving Process.
cynthia