Next: , Previous: Dictionary Creating Variables, Up: Dictionaries


2.6.3 Deleting Variables

These functions remove variables from a dictionary's array of variables. They also destroy the removed variables and free their associated storage.

Deleting a variable to which there might be external pointers is a bad idea. In particular, deleting variables from the active file dictionary is a risky proposition, because transformations can retain references to arbitrary variables. Therefore, no variable should be deleted from the active file dictionary when any transformations are active, because those transformations might reference the variable to be deleted. The safest time to delete a variable is just after a procedure has been executed, as done by DELETE VARIABLES.

Deleting a variable automatically removes references to that variable from elsewhere in the dictionary as a weighting variable, filter variable, SPLIT FILE variable, or member of a vector.

No functions are provided for removing a variable from a dictionary without destroying that variable. As with insertion of an existing variable, there is no reason that this could not be implemented, but so far there has been no need.

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

Deletes var from dict, of which it must be a member.

— Function: void dict_delete_vars (struct dictionary *dict, struct variable *const *vars, size_t count)

Deletes the count variables in array vars from dict. All of the variables in vars must be members of dict. No variable may be included in vars more than once.

— Function: void dict_delete_consecutive_vars (struct dictionary *dict, size_t idx, size_t count)

Deletes the variables in sequential positions idx...idx + count (exclusive) from dict, which must contain at least idx + count variables.

— Function: void dict_delete_scratch_vars (struct dictionary *dict)

Deletes all scratch variables from dict.