• <Helps for GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Statements and Functions
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
        • Average Function
        • Count Function
        • CurOcc Function
        • Delete Function
        • GetOccLabel Function
        • Insert Function
        • Max Function
        • MaxOcc Function
        • Min Function
        • NOccurs Function
        • Seek Function
        • SeekMax Function
        • SeekMin Function
        • SetOccLabel Function
        • SOccurs Function
        • Sort Function
        • Sum Function
        • Swap Function
        • TotOcc Function
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • Appendix
  • <Helps for CSEntry>
  • <Helps for CSBatch>
  • <Helps for CSTab>
  • <Helps for DataViewer>
  • <Helps for TextView>
  • <Helps for TblView>
  • <Helps for MapView>
  • <Helps for TRSWin>
  • <Helps for CSDeploy>
  • <Helps for CSPack>
  • <Helps for CSFreq>
  • <Helps for CSSort>
  • <Helps for CSExport>
  • <Helps for CSReFmt>
  • <Helps for CSDiff>
  • <Helps for CSConcat>
  • <Helps for TRSSetup>
  • <Helps for ParadataViewer>
  • <Helps for ParadataConcat>
  • <Helps for ShpToMap>
  • <Helps for CSIndex>
  • <Helps for Excel2CSPro>
  • <Helps for CSWeb>

Delete Function

 

Format:

b = delete(group[occ]);

 

[occ] is required for multiply-occurring records or items; is not required for singly-occurring records or items

 

Description:

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 was 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.

 

Return value:

The function returns a logical value 1 (true) if successful and 0 (false) otherwise.

 

Example 1 (for multiply-occurring records):

do varying i = totocc(PERSON_REC) until i <= 0 by (-1)

  if rel(i) = notappl and

    sex(i) = notappl and

    age(i) = notappl then

    delete (PERSON_REC(i)); { remove "blank" person records }

  endif;

enddo;

 

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 2nd of four records, the 3rd record shifts to the 2nd position and the 4th records shifts to the 3rd 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.

 

Example 2 (for singly-occurring records):

if h01_type = 6 then { person is homeless, delete record }

  delete (HOUSING); { notice the absence of a subscript }

endif;

 

See also: If Statement, Totocc Function, Do Statement