+ proc_discard_output (ds);
+ split_grouper = casegrouper_create_splits (proc_open (ds), d);
+ output = autopaging_writer_create (dict_get_next_value_idx (d));
+
+ while (casegrouper_get_next_group (split_grouper, &split_group))
+ {
+ struct case_ordering *ordering;
+ struct casereader *ordered;
+ struct casegrouper *by_grouper;
+ struct casereader *by_group;
+ int j;
+
+ /* Sort this split group by the BY variables as primary
+ keys and the rank variable as secondary key. */
+ ordering = case_ordering_create (d);
+ for (j = 0; j < n_group_vars; j++)
+ case_ordering_add_var (ordering, group_vars[j], SRT_ASCEND);
+ case_ordering_add_var (ordering,
+ case_ordering_get_var (sc, i),
+ case_ordering_get_direction (sc, i));
+ ordered = sort_execute (split_group, ordering);
+
+ /* Rank the rank variable within this split group. */
+ by_grouper = casegrouper_create_vars (ordered,
+ group_vars, n_group_vars);
+ while (casegrouper_get_next_group (by_grouper, &by_group))
+ {
+ /* Rank the rank variable within this BY group
+ within the split group. */