• <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>

InValueSet Function

Format
b = invalueset(item_nameʃ, value_set_nameʅ);
Description
The invalueset function determines whether an item's current value is within the permissible ranges of a value set. In addition to specifying the item_name, an optional argument, value_set_name, allows you to specify in which value set to check if the item's value is within the permissible ranges. If no value set is specified, the item's current value set is used.
Return Value
The function returns a logical value of 1 (true) if the item's value is within the value set's ranges and 0 (false) otherwise. If the item has no value set, the function return 1 (true).
Example 1
if not invalueset(P08_MARITAL_STATUS) then
   
errmsg("Marital status is out of range. Value is %d", P08_MARITAL_STATUS);
endif;
Example 2
if D02_SEX = 1 and not invalueset(D05_CAUSE_DEATH, D05_CAUSE_DEATH_MALE_VS) then
   
errmsg("A man cannot die of %l", D05_CAUSE_DEATH);
   
reenter;
endif;
Example 3
If you've included Special Values in your valueset, but you'd rather exclude them in certain situations, you can accomplish this with a call to the Special Function. In the example below, we want to see if the expected educational attainment agrees with the person's age, and issue an error message if it does not.
PROC P12_EDUCATION

if invalueset(AGE) and !special(AGE) then

   
recode AGE :: $     -> numeric age_agrees_with_education;
          < 
5  :: 0     -> true;    // for ages 0-4, no educ attainment expected
          5-10 :: 1     -> true;    // for ages 5-10, primary attainment expected
         11-16 :: 2     -> true;    // for ages 11-16, secondary attainment expected
           16  :: 0,1,2 -> true;    // for ages 17+, any educ attainment allowed
                        -> false;   // any other combination is incorrect
    endrecode;

   
if age_agrees_with_education = false then
       
errmsg("Inconsistency between age (%d) and educ attainment (%d)", AGE, $);
   
endif;

endif;
See also: In Operator, SetValueSet Function, Special Function