elek.me 发表于 2011-1-24 16:11 
- * method 2;
- data tmp1;
- set tmp1.have;
- obs=_n_;
- run;
- proc means data=tmp1 noprint idmin;
- by high notsorted;
- var p_sm;
- id p_sm obs;
- output out=tmp2(drop=_freq_ _type_) min(p_sm)=min max(p_sm)=max;
- run;
- proc means data=tmp1 noprint;
- by high notsorted;
- var p_sm;
- id p_sm obs;
- output out=tmp3(drop=_freq_ _type_) min(p_sm)=min max(p_sm)=max;
- run;
- data want;
- merge tmp1 tmp2 tmp3;
- by obs;
- if high=1 and max^=p_sm then high=.;
- if high=-1 and min^=p_sm then high=.;
- drop min max obs;
- run;
复制代码
楼主的数据里 date 这个变量,看上去是唯一的而且是排序的,如果确实是的话,就没必要用obs这个变量了,程序可以更简练。