• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
      • Introduction to CSPro Language
      • Data Requirements
      • CSPro Program Structure
      • Programming Standards
      • Code Folding
      • Debugging CSPro Applications
      • Declaration Section
        • Compiler Mode
        • Variables
        • Alias Statement
        • User-Defined Functions
        • Array Object
        • Audio Object
        • Case Object
        • Document Object
        • File Object
        • Freq Object
        • Geometry Object
        • HashMap Object
        • Image Object
        • List Object
        • Map Object
        • Pff Object
        • SystemApp Object
        • ValueSet Object
      • Procedural Sections
      • Logic
      • Language Elements
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and 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>

ValueSet Object

In logic, a ValueSet is an object that contains information about the possible values that are considered permissible for a field. Each possible value contains a label, a code (the valid value), and can contain a link to an image shown when the value set is displayed. The ValueSet object, once passed to the setvalueset function, becomes an item's dynamic value set.
Functionality
A ValueSet is a CSPro logic object and the following functions can be called via dot notation:
FunctionDescription
addAdds a single value, or all the values from an existing value set, to the value set.
clearRemoves all values from the value set.
lengthReturns the size of the value set.
randomizeRandomizes the order of entries in the value set.
removeRemoves the value with the specified code from the value set.
showDisplays the value set's labels (similarly to accept) and returns the code of the operator's selection.
sortSorts the order of entries in the value set by either label or code.
 
getLabelReturns the symbol's label.
getNameReturns the symbol's name.
getJsonReturns the symbol's metadata and value represented in JSON.
getValueJsonReturns the symbol's value represented in JSON.
updateValueFromJsonModifies the symbol based on a JSON representation of the value.
In addition to these object functions, ValueSet objects contain two built-in List objects: valueset_name.codes and valueset_name.labels, which contain the codes and labels for the value set. These are read-only List objects and can be used in most ways that List objects can be used.
Several functions accept ValueSet objects as arguments, including: getimage, getlabel, invalueset, maxvalue, minvalue, randomin, randomizevs, and setvalueset. ValueSet objects can also be used with the in operator.
Assignments
ValueSet objects can be assigned to other ValueSet objects, which will replace the initial value set with the values of the assigned value set:
valueset_name = another_valueset_name;
When a ValueSet is used as an argument to a user-defined function, it is passed by reference.
Example
PROC RESPONDENT

preproc

   
ValueSet respondent_valueset;

   
do numeric counter = 1 while counter <= count(PERSON_REC)
       
if AGE(counter) >= 15 and USUAL_MEMBER(counter) = 1 then
            respondent_valueset.
add(NAME(counter), counter);
       
endif;
   
enddo;

   
setvalueset(RESPONDENT, respondent_valueset);
See also: Array Object, List Object