• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
        • Numeric Statement
        • String Statement
        • Alpha Statement
        • config Variable Modifier
        • declare Variable Modifier
        • ensure Variable Modifier
        • persistent Variable Modifier
        • Visual Values for Numeric Fields
        • Relation Statement
        • Function Named Arguments
        • Function Statement
        • Optional Function Parameters
        • Passing Function Arguments by Reference
        • Additional Examples of User-Defined Functions
        • Dot Notation, Logic Objects, and Namespaces
      • Numeric Values
      • String Values
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • StringWriter Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

ensure Variable Modifier

Format
ensure numeric variable_name1ʃ, ... , variable_nameNʅ;
Description
The ensure variable modifier allows for the conditional creation of numeric variables in the PROC GLOBAL section of logic. One or more variable names are specified, and if the name of the variable exists (because of being declared previously in logic, or defined in a dictionary), then it will not be created. If it does not exist, a temporary variable is created just as if it were a declared numeric variable. The initial value of the variable is 0.
This statement is useful when working with applications that reuse blocks of logic with different dictionaries. If a certain routine depends on a dictionary variable, you can use this statement to ensure that the logic compiles without issue. It is important to make sure that your logic works regardless of whether the variable is defined in a dictionary or from the ensure statement.
In versions of CSPro prior to 7.2, you could simulate the behavior of ensure by using set implicit mode.
Example
PROC GLOBAL

ensure numeric SUPERVISOR_CODE;

PROC DATA_TRANSMISSION

   
// assuming that 0 is never a valid value for SUPERVISOR_CODE, then
    // you could have two synchronization routines in your code, one for
    // surveys where there are supervisors (and SUPERVISOR_CODE is defined
    // in a dictionary), and another for surveys where interviewers directly
    // send data to headquarters

   
if SUPERVISOR_CODE = 0 then
        SyncWithHeadquarters();

   
else
        SyncWithSupervisor();

   
endif;
See also: Numeric Statement, config Variable Modifier, persistent Variable Modifier