I know that I've been asking a lot of questions. I have been pushing my SAS envelope quite a bit lately. I have an interesting dataset of GPS data tracking a machine as it travels on a field. It moves from field to headrows on each end. We have 10's of thousands of points taken from GPS and GIS. I am basically trying to quantify the time spent on each leg (up a row, turn around in a headrow, down another row, turn around in a headrow, up another row), and in the future do some other calculations. My current problem Sometimes the machine doesn't cleanly re-enter the field and has to back out, reset, and restart. My approach has been to assign leg numbers to these and when they cross the boundary into another zone. However, I wind up with tiny leg segments that should be lumped in with the point where the machine first exited the field. I anticipated this problem to a degree using a small artificial dataset, used proc means to find out these tiny legs, then reassign their leg using the lag statement. Merged it back and recalculated the legs... worked great. Real life is not as simple. First off, I get multiple tiny leg segments (sometimes close to a dozen, sometimes just a couple). So-- is there a way anyone can think of that I might automate this. I am not generally opposed to doing it by hand, but I have at least 10 of these datasets to go through, and if I can automate it I'd like to. This table represents a subset of data that is generated by my proc means, minus the New_PLT column, which is the column I'd like to find a way to generate automatically. You can see that the machine proceeds from a headrow "HR1" into the field, into "HR2", reenters the field. The attribute that is common is that when I want to lump them in with previous types, there are a series of "legs" (PLeg) with low _FREQ_, and it primarily there is a repeating pattern HR1 FIELD HR1 FIELD repeat... or HR2 FIELD HR2 FIELD repeat... Any ideas? I had some good ones, but I have a headache now. Obs PLeg PLT _TYPE_ _FREQ_ speed New_PLT 51 51 HR1 0 44 2.69545 HR1 52 52 FLD 0 295 2.03322 FLD 53 53 HR2 0 145 0.68828 HR2 54 54 FLD 0 216 2.54676 FLD 55 55 HR1 0 43 3.08837 HR1 56 56 FLD 0 301 2.04751 FLD 57 57 HR2 0 119 0.73277 HR2 58 58 FLD 0 21 0.0619 HR2 59 59 HR2 0 3 0 HR2 60 60 FLD 0 1 0.1 HR2 61 61 HR2 0 2 0.15 HR2 62 62 FLD 0 5 0.12 HR2 63 63 HR2 0 43 0.1 HR2 64 64 FLD 0 211 2.61374 FLD 65 65 HR1 0 35 3.22857 HR1 66 66 FLD 0 317 1.83533 FLD 67 67 HR2 0 331 0.37583 HR2 68 68 FLD 0 243 2.27037 FLD 69 69 HR1 0 86 2.48023 HR1 70 70 FLD 0 22 0.76364 FLD 71 71 HR1 0 43 2.3814 HR1 72 72 FLD 0 255 2.07961 FLD 73 73 HR2 0 232 0.80819 HR2 74 74 FLD 0 208 2.52837 FLD 75 75 HR1 0 2 0.5 HR1 76 76 FLD 0 14 0.70714 HR1 77 77 HR1 0 37 3.94865 HR1 78 78 FLD 0 171 2.84971 FLD 79 79 HR2 0 299 0.64482 HR2 80 80 FLD 0 320 1.83125 FLD 81 81 HR1 0 35 4.18286 HR1 82 82 FLD 0 193 2.51244 FLD 83 83 HR2 0 778 0.31427 HR2 84 84 FLD 0 310 1.80097 FLD 119 119 HR1 0 39 3.76154 HR1 120 120 FLD 0 213 2.11549 FLD 121 121 HR2 0 2 3.45 HR2 122 122 FLD 0 2 2.7 HR2 123 123 HR2 0 57 3.38246 HR2 124 124 FLD 0 570 1.02649 FLD 125 125 HR1 0 428 0.39556 HR1
... View more