• <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
      • 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
      • 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
        • savesetting Function
        • SetLanguage Function
        • SetProperty Function
        • SetValueSet Function
        • 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
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

SetValueSet Function

Feature Upgrade: Starting with CSPro 8.0, it is no longer possible to use Array objects to create dynamic value sets. The ValueSet object must be used instead.
Format
b = setvalueset(item_name, value_set_name);
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 argument is usually an item name but, preceded by the @ symbol, it can also be a string variable or expression, but not a string literal, that evaluates to the name of an item; for example:
setvalueset(@getsymbol(), MY_VALUESET_VS1);
The argument value_set_name is the name of an existing value set in the dictionary for the specified item. The function will replace the values of the current value set for the item with the values from the value set specified by value_set_name, which is either the name of a value set or a string expression that evaluates to a value set name. The value_set_name can also be the name of a dynamic value set.
Return Value
When using a value set specified in the dictionary, the function returns a logical value of 1 (true) if the value set was changed successfully and 0 (false) otherwise (for example, if the value set name is invalid). With dynamic value sets, the function returns the number of codes in the newly created value set.
Example 1
PROC D05_CAUSE_DEATH

onfocus

   
if D02_SEX = 1 then
       
setvalueset(SEX, D05_CAUSE_DEATH_MALE_VS);

   
else
       
setvalueset(SEX, D05_CAUSE_DEATH_FEMALE_VS);

   
endif;
Example 2
PROC DISTRICT

preproc

   
setvalueset(DISTRICT, maketext("DISTRICT_VS%v", PROVINCE));
Example (Dynamic Value Set)
PROC SECOND_FAVORITE_DRINK

preproc

   
ValueSet drink_vs = FAVORITE_DRINK_VS;

    drink_vs.
remove(FAVORITE_DRINK);

   
setvalueset(SECOND_FAVORITE_DRINK, drink_vs);
See also: SetValueSets Function, InValueSet Function