+ /* Execute procedure. */
+ input = proc_open (ds);
+ for (; (c = casereader_read (input)) != NULL; case_unref (c))
+ for (i = 0; i < arc->n_specs; i++)
+ {
+ struct arc_spec *spec = &arc->specs[i];
+ int width = var_get_width (spec->src);
+ const union value *value = case_data (c, spec->src);
+ size_t hash = value_hash (value, width, 0);
+ struct arc_item *item;
+
+ item = find_arc_item (spec, value, hash);
+ if (item == NULL)
+ {
+ item = xmalloc (sizeof *item);
+ value_clone (&item->from, value, width);
+ hmap_insert (spec->items, &item->hmap_node, hash);
+ }
+ }
+ ok = casereader_destroy (input);
+ ok = proc_commit (ds) && ok;
+
+ /* Create transformation. */
+ for (i = 0; i < arc->n_specs; i++)
+ {
+ struct arc_spec *spec = &arc->specs[i];
+ struct arc_item **items;
+ struct arc_item *item;
+ size_t n_items;
+ int src_width;
+ size_t j;
+
+ /* Create destination variable. */
+ spec->dst = dict_create_var_assert (dict, dst_names[i], 0);
+
+ /* Create array of pointers to items. */
+ n_items = hmap_count (spec->items);
+ items = xmalloc (n_items * sizeof *items);
+ j = 0;
+ HMAP_FOR_EACH (item, struct arc_item, hmap_node, spec->items)
+ items[j++] = item;
+ if (!arc->global_items)
+ assert (j == n_items);
+
+ /* Sort array by value. */
+ src_width = var_get_width (spec->src);
+ sort (items, n_items, sizeof *items, compare_arc_items, &src_width);
+
+ /* Assign recoded values in sorted order. */
+ for (j = 0; j < n_items; j++)