8 Metric = put(Percentile,percent8.);
28 select distinct Variable
29 into:Vars separated by
' ' 33 data Distributions(keep=Variable Value Count Percent Cumulative Cum_Percent);
34 length Variable $32 Value 8 Metric $8;
35 format Count Cumulative total comma12. Percent Cum_Percent percent7.2;
36 array _Variables(*) &Vars;
38 dcl hash ptiles(dataset:
"ptiles",ordered:
"A");
39 ptiles.defineKey(
"Percentile");
40 ptiles.defineData(
"Percentile",
"Metric");
42 dcl hiter iter_ptiles(
"ptiles");
44 dcl hash results(ordered:
"A",multidata:
"Y");
45 results.defineKey(
"Variable",
"Metric");
46 results.defineData(
"Variable",
"Metric",
"Value");
49 dcl hash HoH(ordered:
"A");
51 HoH.defineData (
"H",
"ITER",
"Variable",
"Total",
"Sum",
"maxCount");
56 do I = 1 to dim(_Variables);
57 h = _new_ hash(ordered:
"A");
58 h.defineKey(vname(_Variables(i)));
59 h.defineData(vname(_Variables(i)),
"Count");
61 iter = _new_ hiter(
"H");
62 Variable = vname(_Variables(i));
67 do Rows = 1 by 1 until(lr);
69 do I = 1 to dim(_Variables);
71 if missing(_Variables(i)) then
continue;
72 if h.find() ne 0 then Count = 0;
77 maxCount = max(Count,maxCount);
81 do I = 1 to dim(_Variables);
86 do j = 1 to h.num_items;
88 Percent = divide(Count,Total);
91 Cum_Percent = divide(_Cum,Total);
92 Value = _Variables(I);
95 then results.add(Key:Variable
101 if last le Percentile le Cum_Percent then
103 if percentile ne 1 then results.add();
104 if iter_ptiles.next() ne 0 then percentile = 1;
108 Value = divide(Sum,Total);
112 Value = _Variables(I);
116 Value = _Variables(I);
120 results.output(dataset:
"Metrics");