由买买提看人间百态

topics

全部话题 - 话题: testxx
(共0页)
d*******1
发帖数: 854
1
来自主题: Statistics版 - 请教SAS问题
太复杂,又想不出别的好办法。
data test;
input x y;
cards;
1 2
2 0
3 2
4 2
5 2
6 2
7 2
8 2
9 0
10 2
;
run;
data testx;
set test;
retain flgx;
if _n_=1 and x ne 5 then flgx=-1;
else if x=5 then flgx=1;
if y ne 2 then flgy=-1;
else flgy=1;
run;
proc sort data=testx out=testxx; by flgx flgy; run;
data result;
set testxx;
by flgx flgy;
if (last.flgy and flgx=-1 and flgy=-1) or
(first.flgy and flgx=1 and flgy=-1)
then output;
drop flgx flgy;
run;
d*******1
发帖数: 854
2
来自主题: Statistics版 - 请教SAS问题
gees, that is almost entirely different question! try the followings:
data test;
input x y;
cards;
1 2
2 0
3 2
4 2
5 2
6 2
7 2
8 2
9 0
10 2
;
run;
data testx;
set test;
retain flgx;
if _n_=1 and x ne 5 then flgx=-1;
else if x=5 then flgx=1;
if y ne 2 then flgy=-1;
else flgy=1;
order=_n_;
run;
proc sort data=testx out=testxx; by flgx flgy; run;
data result;
set testxx;
by flgx flgy;
if (last.flgy and flgx=-1 and flgy=-1) or
(first.flgy and flgx=1 and flgy=-1)
then output;
drop flgx flgy;
run;
dat
(共0页)