Next: , Previous: , Up: Dictionaries   [Contents][Index]


2.6.6 Weight Variable

A data set’s cases may optionally be weighted by the value of a numeric variable. See WEIGHT in PSPP Users Guide, for a user view of weight variables.

The weight variable is written to and read from system and portable files.

The most commonly useful function related to weighting is a convenience function to retrieve a weighting value from a case.

Function: double dict_get_case_weight (const struct dictionary *dict, const struct ccase *case, bool *warn_on_invalid)

Retrieves and returns the value of the weighting variable specified by dict from case. Returns 1.0 if dict has no weighting variable.

Returns 0.0 if c’s weight value is user- or system-missing, zero, or negative. In such a case, if warn_on_invalid is non-null and *warn_on_invalid is true, dict_get_case_weight also issues an error message and sets *warn_on_invalid to false. To disable error reporting, pass a null pointer or a pointer to false as warn_on_invalid or use a msg_disable/msg_enable pair.

The dictionary also has a pair of functions for getting and setting the weight variable.

Function: struct variable * dict_get_weight (const struct dictionary *dict)

Returns dict’s current weighting variable, or a null pointer if the dictionary does not have a weighting variable.

Function: void dict_set_weight (struct dictionary *dict, struct variable *var)

Sets dict’s weighting variable to var. If var is non-null, it must be a numeric variable in dict. If var is null, then dict’s weighting variable, if any, is cleared.


Next: Filter Variable, Previous: Renaming Variables, Up: Dictionaries   [Contents][Index]