• <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 Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
        • Compare Function
        • Concat Function
        • String Concatenation Operator
        • Edit Function
        • GetBuffer Function
        • Length Function
        • MakeText Function
        • Message Formatting Options
        • Pos Function
        • PosChar Function
        • RegExMatch Function
        • Replace Function
        • StartsWith Function
        • Strip Function
        • ToLower Function
        • ToNumber Function
        • ToUpper Function
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
      • Export Attributes
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Appendix
  • <Helps for CSEntry>
  • <Helps for CSBatch>
  • <Helps for CSTab>
  • <Helps for DataViewer>
  • <Helps for TextView>
  • <Helps for TblView>
  • <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 CSIndex>
  • <Helps for Excel2CSPro>
  • <Helps for CSWeb>

Length Function

Format
i = length(string_expression);
Description
The function length calculates the length of an alphanumeric string_expression. If the string is a dictionary item, the value returned is the length of the item. If it the string is the result of a function, the value returned is the length of the string returned by the function.
Return Value
The function returns the length of the string as an integer value. If using an alpha variable or a dictionary item, you may want to strip the string before calculating its length.
Example
alpha (30) NAME = "John Henry";
length(NAME);                   // returns 30
length(strip(NAME));            // returns 10
Uses on Lists and Arrays
The length function also operates on lists and arrays. When applied to a list, it returns the number of elements in the list. When applied on an array, it returns the size of an array dimension.
Format
i = length(list_name);
i = 
length(array_nameʃ, dimensionʅ);
Examples
array string usmca_countries(3) = "Canada", "Mexico", "United States";
length(usmca_countries); // returns 3;

// ...

array AgeSexDeckArray(AGE_VS, SEX_VS);

do numeric age_counter = 1 while age_counter <= length(AgeSexDeckArray, 1)
   
do numeric sex_counter = 1 while sex_counter <= length(AgeSexDeckArray, 2)
       
// ...
    enddo;
enddo;
See also: Array.Length Function