Hey folks, I am wondering if there are any issues with the approach I'm taking in using this program with the LAG command. What I am looking to do is read in the previous LagClusterID if certain conditions are met (if EucDistance < 656 ft, 15 < BaseTime - LagTime < 720, and points are consecutive). I've included code below and attached two documents, one for Dataset2 and one for Dataset3. The first image is Dataset2, and the second is Dataset3. What I am trying to do in Dataset3 is to append Cluster values 17262 to LagIDs 16689 and 16690 in addition to point 16688. The attached data has been cleansed of any features which may identify any locations or times. Let me know if these alterations pose any issues. Any help is appreciated. Thanks! Data Dataset2; set Dataset1; BaseDum = BaseClusterID; LagDum = lag(BaseDum); Lag1Dum = LagDum; if (substr(LagClusterID,1,7) = 'cluster') AND (substr(LagDum,1,7) ne 'cluster') then LagClusterID = LagDum; run; Data Dataset3; set Dataset2; if (substr(BaseClusterID,1,7) = 'cluster') AND (substr(LagDum,1,7) ne 'cluster') AND (substr(lag(LagDum),1,7) ne 'cluster') then Lag1Dum = lag1(LagDum); if (substr(lag1(LagClusterID),1,7) ne 'cluster') AND (substr(LagClusterID,1,7) ne 'cluster') then LagClusterID = Lag1Dum; run;
... View more