+static void
+subcommand_save (int save, pspp_linreg_cache *lc, const struct casefile *cf, int *is_missing)
+{
+ int i;
+ int case_num;
+ double residual;
+ const union value **vals = NULL;
+ const union value *obs = NULL;
+ struct casereader *r;
+ struct ccase c;
+
+ assert (lc != NULL);
+ assert (lc->depvar != NULL);
+ assert (is_missing != NULL);
+
+ if (save)
+ {
+ vals = xnmalloc (n_variables, sizeof (*vals));
+ for (r = casefile_get_reader (cf); casereader_read (r, &c);
+ case_destroy (&c))
+ {
+ case_num = casereader_cnum (r) - 1;
+ if (!is_missing[case_num])
+ {
+ for (i = 0; i < n_variables; ++i)
+ {
+ vals[i] = case_data (&c, v_variables[i]->fv);
+ if (v_variables[i]->index == lc->depvar->index)
+ {
+ obs = vals[i];
+ }
+ }
+ residual = (*lc->residual) ((const struct variable **) v_variables,
+ (const union value **) vals, obs, lc, n_variables);
+ }
+ }
+ free (vals);
+ }
+}