SAS中文论坛

标题: try this one [打印本页]

作者: shiyiming    时间: 2005-10-27 00:51
标题: try this one
proc sort data=tem;  by id date;  run;
data tem_r(keep=id sdate edate new_vol);
     set tem;
         by id;
         retain this_date;
         format sdate edate yymmdd10.;
     lag_id=lag(id);
         lag_vol=lag(vol);
         lag_date =lag(date);
     
         if first.id then this_date=date;
            else do;
                        if lag_vol^=vol then do;
                        id =lag_id;
                                edate=lag_date;
                        new_vol=lag_vol;
                        sdate=this_date;
                        this_date=date;
                        output;
                end;
         end;

          if last.id then do;
                sdate=this_date;
                new_vol=vol;
                edate=date;
                output;
          end;
run;




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2