Home page  
Help >
CalcObject Function Distinct()
Version 7.11
CalcObject Function Distinct() CalcObject Function Distinct()

DISTINCT() is a number-valued function that builds a temporary internal list in order to determine if a given value is distinct. Each item that is submitted to the DISTINCT() function is added to the list if it is not already present. DISTINCT() returns a non-zero value if the submitted item did not previously exist in the list; i.e., it is distinct; it returns zero if the submitted item did previously exist in the list; i.e., it is non distinct.
    Syntax is
      DISTINCT(<value>)
         <value> is the value to be tested; it can be numeric or
            alpha; 
This function can be used in a CalcObject to determine on an ad hoc basis if a value or combination of values is distinct.
For a singleton alpha column or a singleton alpha variable, the singleton itself can be used as the parameter for distinct();
For a singleton numeric column or a singleton numeric variable, the singleton itself can be used as the parameter for distinct();
For multiple alpha columns and/or alpha variables, use the concatenation operator to create a new alpha variable:
      SET FN/N = COLUMN1 ! COLUMN2 ! COLUMN3
Note that the /N option is necessary here for any cases that might include SQL null; in general, it is advisable to use the /N option in all instances of SET and CALC with the distinct() function.
For a combination of alpha and numeric columns and/or variables, it is necessary first to convert all numberic items to strings. The easiest way to do this in a generic way is:
      SET/N FNi = COLUMNi (+E16.10)
      for each i that is a numeric column or value.
Then
      SET FN/N = COLUMN1 ! COLUMN2 ! COLUMN3 ! FNi ...

Copyright © 2019 , WhamTech, Inc.  All rights reserved. This document is provided for information purposes only and the contents hereof are subject to change without notice. Names may be trademarks of their respective owners.