b = delete(group_nameʃ(occurrence)ʅ);
b = delete(group_name, first_occurrence)ʃ, last_occurrenceʅ);
The
delete function removes incomplete, or otherwise unneeded, records or item occurrences from the current case. It can be used to remove singly- or multiply-occurring records, although if the record is non-repeating (such as the housing record in a typical census application), then it must be defined as
"Required=No" in the dictionary. This function is primarily intended for batch applications. It should be used with extreme caution in data entry applications because of possible conflicts between the operator's actions and the program logic.
The first syntax deletes a single occurrence of the record. When deleting a singly-occurring record, it is not necessary to specify the occurrence. The second syntax deletes one or more occurrences of a record, starting with the last_occurrence and deleting up to the first_occurrence. This allows for the mass deletion of record occurrences.
The function returns a logical value of 1 (true) if successful and 0 (false) otherwise.
In this example blank person records are deleted from the case. Records following any deleted record are "shifted up" to cover the vacated area. For example, if you delete the second of four records, the third record shifts to the second position and the fourth record shifts to the third position.
It is best to delete the records starting with the last record and moving toward the first. Use a subscript that starts at the last occurrence then is decremented (decreased by 1). In this way you will not need to worry about the records that are shifting positions.
// if person is homeless, delete the record
if H01_TYPE = 6 then
delete(HOUSING_REC); // note the absence of a subscript
endif;