Product(s): | Cube |
Version(s): | 6.1 to 6.5 |
Area: | Matrix |
LOOKUP statement is another very useful function available in Cube. Users can use this in HIGHWAY, MATRIX, NETWORK and PT Programs. We will use MATRIX to demonstrate the usage of LOOKUP statement and its related sub keywords based on a very simple lookup table we prepared.
Input Lookup Table:
NOTE: There are only two fields, let’s assume the first column is the data index and the second column gives the value for this data point.
Now, we are interested in searching for values in the table below:
1
2
3
4
2.1
2.5
2.8
Depending on what users specify the LOOKUP function, the return values will be different!
Now why somebody would care about this?
In our example, we only have values for 2 and 3. In its simplest form, LOOKUP statement can only return correct value for 2 and 3. What should we do if we want to get a value between 2 to 3, lower than 2 and higher than 2? That all depends on the users. Cube gives the capability for the users to specify return values for something that is not in the lookup table. Also, many times, the data are NOT perfect, if we have something out of the range in the lookup table, we can detect them and report (use IF and PRINT) to the users or abort the model.
How to achieve these?
Please see the details in the attached catalog on LOOKUP, INTERPOLATE, NEAREST, FAIL[1], FAIL[2] and FAIL[3]. Again, users are encouraged to twist the input files and script to understand and explore LOOKUP statement.