我有这样一个dataset:
Name Maturity Upfront Bid
[code:w6vnonlo]data aa;
input name$ maturity upfront bid;
datalines;
A 3 10 500
A 3 20 500
A 3 . 980
A 5 . 300
A 5 . 350
A 5 . 360
B 3 23 500
B 3 21 500
B 5 25 500
B 5 . 500
;
[/code:w6vnonlo]
这里同一个name同一个maturity的为同一个产品。同一个产品中有的含upfront,有的不含。我想从中找出同一个产品中既有upfront也含无upfront的,即上面数据要输出成:
Name Maturity Upfront Bid
A 3 10 500
A 3 20 500
A 3 . 980
B 5 25 500
B 5 . 950
[code:2gy2dxzb]proc sort data=aa out=temp;
by name maturity;
run;
data temp(drop=flag:);
do _n_=1 by 1 until(last.maturity);
set temp;
by name maturity;
if upfront=. then flag1=1;
else flag2=1;
end;
if flag1 and flag2 then flag=1;
do _n_=1 to _n_;
set temp;
by name maturity;
if flag=1 then output;
end;
run;[/code:2gy2dxzb]