I will try to address all of the comments from my Array thread, which are essentially asking me to 'start over'. 🙂 The data set I have is a set of field measurements. Operating data. Obs Group local_dttm Speed weight Temperature Cat 1 8784 04JAN2021:17:20:00.000000 2,329.65 -426.06 3.35 0.97 2 8784 04JAN2021:17:30:00.000000 2,330.98 -480.73 3.74 0.97 3 8784 04JAN2021:17:40:00.000000 2,329.38 -447.44 3.88 0.97 4 8784 04JAN2021:17:50:00.000000 2,327.91 -365.98 3.74 0.98 5 8784 04JAN2021:18:00:00.000000 2,329.30 -225.05 3.62 0.99 6 8784 04JAN2021:18:10:00.000000 2,329.98 -234.77 3.37 0.99 7 8784 04JAN2021:21:10:00.000000 2,331.31 -87.29 2.01 0.99 8 8784 04JAN2021:21:20:00.000000 2,329.99 -77.5 1.81 0.99 9 8784 04JAN2021:21:30:00.000000 2,330.17 12.78 1.83 1 10 8784 04JAN2021:21:40:00.000000 2,330.07 16.9 1.68 1 11 8784 04JAN2021:21:50:00.000000 2,330.94 2.36 1.94 1 12 8784 04JAN2021:22:00:00.000000 2,329.89 -33.22 2.03 0.99 13 8784 04JAN2021:22:10:00.000000 2,329.93 -142.8 2 0.98 14 8784 04JAN2021:22:20:00.000000 2,330.20 -141.09 1.95 0.98 15 8784 04JAN2021:22:30:00.000000 2,329.50 -129.25 1.78 0.98 16 8784 04JAN2021:22:40:00.000000 2,330.17 -133.56 1.69 0.98 17 8784 04JAN2021:22:50:00.000000 2,329.39 -152.02 1.56 0.98 18 8784 04JAN2021:23:00:00.000000 2,330.09 -182.97 1.52 0.98 19 8784 04JAN2021:23:10:00.000000 2,329.59 -169.54 1.29 0.98 20 8784 04JAN2021:23:20:00.000000 2,330.77 -221.52 1.31 0.98 21 8784 04JAN2021:23:30:00.000000 2,329.89 -236.03 1.61 0.98 22 8784 04JAN2021:23:40:00.000000 2,329.93 -243.14 1.7 0.97 23 8784 04JAN2021:23:50:00.000000 2,329.21 -234.27 1.6 0.97 24 8784 05JAN2021:00:00:00.000000 2,328.60 -229.13 . 0.97 25 8784 05JAN2021:00:10:00.000000 2,330.11 -188.98 1.49 0.98 26 8784 05JAN2021:00:20:00.000000 2,328.01 -216.42 1.34 0.98 27 8784 05JAN2021:00:30:00.000000 2,308.17 -213.41 1.23 0.98 28 8784 05JAN2021:00:40:00.000000 2,327.50 -212.38 1.39 . My desired data set would show if the operating point is over a limit (yes/no could be inside/outside or 1/0, etc.) Obs Group local_dttm Speed weight Temperature Cat Exceeds_limits 1 8784 04JAN2021:17:20:00.000000 2,329.65 -426.06 3.35 0.97 yes 2 8784 04JAN2021:17:30:00.000000 2,330.98 -480.73 3.74 0.97 No 3 8784 04JAN2021:17:40:00.000000 2,329.38 -447.44 3.88 0.97 No 4 8784 04JAN2021:17:50:00.000000 2,327.91 -365.98 3.74 0.98 No 5 8784 04JAN2021:18:00:00.000000 2,329.30 -225.05 3.62 0.99 No 6 8784 04JAN2021:18:10:00.000000 2,329.98 -234.77 3.37 0.99 No 7 8784 04JAN2021:21:10:00.000000 2,331.31 -87.29 2.01 0.99 No 8 8784 04JAN2021:21:20:00.000000 2,329.99 -77.5 1.81 0.99 No 9 8784 04JAN2021:21:30:00.000000 2,330.17 12.78 1.83 1 No 10 8784 04JAN2021:21:40:00.000000 2,330.07 16.9 1.68 1 Yes 11 8784 04JAN2021:21:50:00.000000 2,330.94 2.36 1.94 1 No 12 8784 04JAN2021:22:00:00.000000 2,329.89 -33.22 2.03 0.99 No 13 8784 04JAN2021:22:10:00.000000 2,329.93 -142.8 2 0.98 No 14 8784 04JAN2021:22:20:00.000000 2,330.20 -141.09 1.95 0.98 No 15 8784 04JAN2021:22:30:00.000000 2,329.50 -129.25 1.78 0.98 No 16 8784 04JAN2021:22:40:00.000000 2,330.17 -133.56 1.69 0.98 No 17 8784 04JAN2021:22:50:00.000000 2,329.39 -152.02 1.56 0.98 Yes 18 8784 04JAN2021:23:00:00.000000 2,330.09 -182.97 1.52 0.98 No 19 8784 04JAN2021:23:10:00.000000 2,329.59 -169.54 1.29 0.98 No 20 8784 04JAN2021:23:20:00.000000 2,330.77 -221.52 1.31 0.98 No 21 8784 04JAN2021:23:30:00.000000 2,329.89 -236.03 1.61 0.98 Yes 22 8784 04JAN2021:23:40:00.000000 2,329.93 -243.14 1.7 0.97 No 23 8784 04JAN2021:23:50:00.000000 2,329.21 -234.27 1.6 0.97 No 24 8784 05JAN2021:00:00:00.000000 2,328.60 -229.13 . 0.97 No 25 8784 05JAN2021:00:10:00.000000 2,330.11 -188.98 1.49 0.98 No 26 8784 05JAN2021:00:20:00.000000 2,328.01 -216.42 1.34 0.98 No 27 8784 05JAN2021:00:30:00.000000 2,308.17 -213.41 1.23 0.98 No 28 8784 05JAN2021:00:40:00.000000 2,327.50 -212.38 1.39 . Yes The final report by group, which is simple once the above is available. Group Percent exceeds 8784 1.00% 5694 1.50% 5289 3.00% 4535 0.10% 2489 8.00% 3527 4.00% The limits data set defines convex polygons. I cannot use a simple "is speed greater than the speed limit". I need to use something like Ginside, but my polygons are not adjacent. They lay on top of each other. A lower temperature provides a larger polygon with the same center and some identical vertices. I can reduce my problem to two dimensions (two variables). The other variable (actually 2), I would use to choose the correct set of limits (speed/weight). Here is a look at the limits data set, from which 10 different polygon vertices are obtained. each cat/temperature combination represents one array. cat Temperature speed weight 0.9 30 0 602 0.9 30 50 602 0.9 30 50 1128 0.9 30 1953 1128 0.95 30 2161 395 0.95 30 2162 339 0.95 30 2162 282 0.95 30 2163 226 0.95 30 2164 169 0.95 30 2164 113 0.9 35 1978 -564 0.9 35 1974 -621 0.9 35 1968 -677 0.95 35 2037 1016 0.95 35 2050 959 0.95 35 2062 903 0.95 35 2071 846 0.95 35 2079 790 0.95 35 2085 734 0.95 35 2090 677 0.95 35 2092 621 My thought was to step through each operating data set observation, Determine which set of limits to use (the rows where op-cat and op-temperature fall within a cat and temp in the limits data set) Make the calculation for each operating set observation Write the result to a new variable in the operating data set This is what I have. Any recommendations on how to accomplish the above is appreciated. data op_results;
set op_base;
/* original idea was to load a set of arrays that I can step through later in this data step but am not seeing a path */
create set of applicable_array (plural) here
/* initialize some variables */
negatives = 0;
positives = 0;
zeroes = 0;
/* step through the limits and determine if the operating point is to the right or left SIDE of each line drawn by each vertices pair in the limits data set/array */
do j = 2 to numrow(applicable_array,1);
side = sign(
(speed - applicable_array[i-1,1])*(applicable_array[i,2]-applicable_array[i-1,2]) -
(weight - applicable_array[i-1,2])*(applicable_array[i,1]-applicable_array[i-1,1])
);
if side = -1 then negatives++;
else if side = 1 then positives++;
else zeroes++;
end;
IF negatives = 0 and positives > 0 then exceedance = 'inside'; /* inside/outside could be yes/no or 1/0, etc. */
else exceedance = 'outside';
run;
... View more