• <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
      • Multiple Occurrence Functions
      • General Functions
        • Compress Function
        • Decompress Function
        • Diagnostics Function
        • Encode Function
        • ErrMsg Function
        • ExecSystem Function (Desktop)
        • ExecSystem Function (Mobile)
        • ExecPFF Function
        • GetProperty Function
        • GetLabel Function
        • GetLanguage Function
        • GetSymbol Function
        • GetValueLabel Function
        • Hash Function
        • HtmlDialog Function
        • InValueSet Function
        • Invoke Function
        • IsChecked Function
        • LoadSetting Function
        • LogText Function
        • MaxValue Function
        • MinValue Function
        • Paradata Function
        • PathConcat Function
        • PathName Function
        • Report Function (Deprecated)
        • SaveSetting Function
        • SetLanguage Function
        • SetProperty Function
        • SetReportData Function (Deprecated)
        • SetValueSet Function
        • SetValueSet Function With Arrays
        • SetValueSets Function
        • Special Function
        • SqlQuery Function
        • Stop Function
        • SysParm Function
        • Tr Function
        • Trace Function
        • UUID Function
        • View Function
        • Warning Function
      • 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>

SetValueSet Function With Arrays

Feature Upgrade: Starting with CSPro 7.3, you should no longer use this function as it may soon be removed from CSPro. To replicate the behavior of the function, you can use the setvalueset function with dynamic value sets.
Format
i = setvalueset(item_name, codes_array, labels_arrayʃ, images_arrayʅ);
Description
The setvalueset function allows you to dynamically change an item's current value set. An item's current value set is used to determine whether or not entered values are out of range. The current value set is also used to provide the value choices displayed in capture types. The changing of a value set is not permanent; it remains in effect only during the processing of the current case or until the next call to setvalueset.
The item_name is the name of the item in the data dictionary whose value set is to be changed. The second argument, codes_array, is an array of codes to use in the new value set and the third argument, labels_array, is an array of labels that correspond to the values in the codes array (the nth element of the labels array is the label for the nth element in the codes array). If the item is numeric, codes_array must be a numeric array. If the item is alphanumeric, codes_array must be a string array. The labels_array must always be a string array. The optional fourth argument, images_array, is a string array pointing to image filenames to be used as value set images.
When working with the codes_array, to indicate the end of a numeric array, assign the special value notappl to the position after the last valid code. To indicate the end of a string array, assign a blank value. This indicates when to stop loading values from the array.
In versions of CSPro earlier than 6.0, the value set labels and codes array needed to start at index position 0. Zero-based arrays are still permitted, but if a one-based array is passed to the function (and the zeroth element has never been assigned to), then CSPro will start processing the dynamic value set at array position 1.
Return Value
The function returns the number of codes in the newly created value set.
Example
PROC GLOBAL

array vsCodes(100);
array string vsLabels(100);

PROC DISTRICT

preproc

    vsCodes(
1) = 1;
    vsLabels(
1) = "District 1";

    vsCodes(
2) = 2;
    vsLabels(
2) = "District 2";

    vsCodes(
3) = 3;
    vsLabels(
3) = "District 3";

    vsCodes(
4) = notappl; // mark the end of the array

   
setvalueset(DISTRICT, vsCodes, vsLabels);
See also: SetValueSet Function