* Updated existing functions to pass int * to dict_get_case_weight().
{
struct agr_var *iter;
double weight;
+ int bad_warn = 1;
- weight = dict_get_case_weight (default_dict, input);
+ weight = dict_get_case_weight (default_dict, input, &bad_warn);
for (iter = agr->vars; iter; iter = iter->next)
if (iter->src)
static int
calc_general (struct ccase *c, void *aux UNUSED)
{
+ int bad_warn = 1;
+
/* Case weight. */
- double weight = dict_get_case_weight (default_dict, c);
+ double weight = dict_get_case_weight (default_dict, c, &bad_warn);
/* Flattened current table index. */
int t;
static int
calc_integer (struct ccase *c, void *aux UNUSED)
{
+ int bad_warn = 1;
+
/* Case weight. */
- double weight = dict_get_case_weight (default_dict, c);
+ double weight = dict_get_case_weight (default_dict, c, &bad_warn);
/* Flattened current table index. */
int t;
/* Accumulated results. */
double missing_listwise; /* Sum of weights of cases missing listwise. */
double valid; /* Sum of weights of valid cases. */
- int bad_weight; /* Nonzero if a bad weight has been found. */
+ int bad_warn; /* Warn if bad weight found. */
enum dsc_statistic sort_by_stat; /* Statistic to sort by; -1: name. */
int sort_ascending; /* !0: ascending order; 0: descending. */
unsigned long show_stats; /* Statistics to display. */
dsc->format = DSC_LINE;
dsc->missing_listwise = 0.;
dsc->valid = 0.;
- dsc->bad_weight = 0;
+ dsc->bad_warn = 1;
dsc->sort_by_stat = DSC_NONE;
dsc->sort_ascending = 1;
dsc->show_stats = dsc->calc_stats = DEFAULT_STATS;
/* Data pass. */
multipass_procedure_with_splits (calc_descriptives, dsc);
- if (dsc->bad_weight)
- msg (SW, _("At least one case in the data file had a weight value "
- "that was system-missing, zero, or negative. These case(s) "
- "were ignored."));
/* Z-scoring! */
if (z_cnt)
reader = casefile_get_reader (cf);
while (casereader_read (reader, &c))
{
- double weight = dict_get_case_weight (default_dict, c);
+ double weight = dict_get_case_weight (default_dict, c, &dsc->bad_warn);
if (weight <= 0.0)
- {
- dsc->bad_weight = 1;
continue;
- }
-
+
/* Check for missing values. */
if (listwise_missing (dsc, c))
{
reader = casefile_get_reader (cf);
while (casereader_read (reader, &c))
{
- double weight = dict_get_case_weight (default_dict, c);
+ double weight = dict_get_case_weight (default_dict, c,
+ &dsc->bad_warn);
if (weight <= 0.0)
continue;
return d->weight;
}
-/* Returns the value of D's weighting variable in case C, except
- that a negative weight is returned as 0. Returns 1 if the
- dictionary is unweighted. */
+/* Returns the value of D's weighting variable in case C, except that a
+ negative weight is returned as 0. Returns 1 if the dictionary is
+ unweighted. Will warn about missing, negative, or zero values if
+ warn_on_invalid is nonzero. The function will set warn_on_invalid to zero
+ if an invalid weight is found. */
double
-dict_get_case_weight (const struct dictionary *d, const struct ccase *c)
+dict_get_case_weight (const struct dictionary *d, const struct ccase *c,
+ int *warn_on_invalid)
{
assert (d != NULL);
assert (c != NULL);
else
{
double w = c->data[d->weight->fv].f;
- if (w < 0.0)
+ if ( w < 0.0 || w == SYSMIS || is_num_user_missing(w, d->weight) )
w = 0.0;
+ if ( w == 0.0 && *warn_on_invalid ) {
+ *warn_on_invalid = 0;
+ msg (SW, _("At least one case in the data file had a weight value "
+ "that was user-missing, system-missing, zero, or "
+ "negative. These case(s) were ignored."));
+ }
return w;
}
}
{
double weight;
int i;
+ int bad_warn = 1;
- weight = dict_get_case_weight (default_dict, c);
+ weight = dict_get_case_weight (default_dict, c, &bad_warn);
for (i = 0; i < n_variables; i++)
{
levene_calc (const struct ccase *c, void *_l)
{
int i;
+ int warn = 0;
struct levene_info *l = (struct levene_info *) _l;
const union value *gv = &c->data[l->v_indep->fv];
struct group_statistics key;
- double weight = dict_get_case_weight(default_dict,c);
+ double weight = dict_get_case_weight(default_dict,c,&warn);
/* Skip the entire case if /MISSING=LISTWISE is set */
levene2_calc (const struct ccase *c, void *_l)
{
int i;
+ int warn = 0;
struct levene_info *l = (struct levene_info *) _l;
- double weight = dict_get_case_weight(default_dict,c);
+ double weight = dict_get_case_weight(default_dict,c,&warn);
const union value *gv = &c->data[l->v_indep->fv];
struct group_statistics key;
static struct cmd_t_test cmd;
-
+static int bad_weight_warn;
int
cmd_t_test(void)
else
value_is_missing = is_missing;
+ bad_weight_warn = 1;
+
multipass_procedure_with_splits (calculate, &cmd);
n_pairs=0;
int i;
struct cmd_t_test *cmd = (struct cmd_t_test *)_cmd;
- double weight = dict_get_case_weight(default_dict,c);
+ double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
/* Skip the entire case if /MISSING=LISTWISE is set */
struct cmd_t_test *cmd = (struct cmd_t_test *)cmd_;
- double weight = dict_get_case_weight(default_dict,c);
+ double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
/* Skip the entire case if /MISSING=LISTWISE is set */
if ( cmd->miss == TTS_LISTWISE )
struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_;
- double weight = dict_get_case_weight(default_dict,c);
+ double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
/* Skip the entire case if /MISSING=LISTWISE is set ,
AND one member of a pair is missing */
const union value *gv = &c->data[indep_var->fv];
- const double weight = dict_get_case_weight(default_dict,c);
+ const double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
if ( value_is_missing(gv,indep_var) )
{
size_t count, char **err_name);
struct variable *dict_get_weight (const struct dictionary *);
-double dict_get_case_weight (const struct dictionary *, const struct ccase *);
+double dict_get_case_weight (const struct dictionary *,
+ const struct ccase *, int *);
void dict_set_weight (struct dictionary *, struct variable *);
struct variable *dict_get_filter (const struct dictionary *);