• <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
      • Procedural Sections
      • Logic
      • Language Elements
        • Version
        • Delimiters
        • Comments
        • Preprocessor
        • Variables and Constants
        • Expressions
        • Operators
          • Operators
          • String Comparisons
          • In Operator
          • Has Operator
          • If and Only If Operator
          • Operator Precedence
          • And/Or Truth Table
        • Files
        • Miscellaneous
    • 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>

In Operator

Description
The in operator is used in logical expressions to test whether an item or variable is within a set of values or ranges. The item or variable can be a number or a string. A range of values is separated by a colon, for example 1:5. Elements of a list of values or ranges are separated by commas, for example 1,3:5,7. You can also use special to mean all special values (as in the special function). The in operator can also be used to test whether a value is in several CSPro objects:
  • A List can be used to determine if the value is located in the List's values (as in the List.seek function).
  • A value set can also be used to test whether a value is in the value set's codes (as in the invalueset function).
Example 1
if RELATIONSHIP in 1:5 then
// is the same as...
if RELATIONSHIP >= 1 and RELATIONSHIP <= 5 then
Example 2
if WORK in 1, 3, 5 then
// is the same as...
if WORK = 1 or WORK = 3 or WORK = 5 then
Example 3
if X in 1:4, missing, refused then
// is the same as...
if ( X >= 1 and X <= 4 ) or X = missing or X = refused then
Example 4
if NAME in "A":"MZZ" then
// is the same as...
if NAME >= "A" and NAME <= "MZZ" then
Example 5
if AGE in AGE_TEENAGE_VS, special then
// is the same as...
if invalueset(AGE, AGE_TEENAGE_VS) or special(AGE) then
See also: Has Operator