SELECT LEVEL

<< Click to Display Table of Contents >>

Navigation:  Reference > Commands >

SELECT LEVEL

The SELECT LEVEL command is used in surveys with more than one level of data (trailer surveys). It is used in the definition of variables and the checking of variables used on tables.

For variable definitions the command:

SELECT LEVEL x,

specifies one or more "levels" at which a variable is available for tabulation. X may be a single number or a set of numbers separated by "." characters: for example:

select level 1,

select level 2.3.4,

select level 0,

Up to 16 levels (numbered 1-16) may be specified; each SELECT LEVEL command replaces any previous settings. The standard setting for LEVEL is 0 which implies that the variable is available at all levels.

Following a SELECT LEVEL command, all new variables defined are set to be available at the specified levels.

The SELECT LEVEL command also applies to T (tabulate) commands; if a table is incremented at a particular level, then the stub and banner variables must be available at that level (or level 0).

For an example, consider the following partial CL script:

dm $level=f,f,

fl='All level 1;All level 2',

!

select level 1.2,

dm $v2 = ...,

dm $v3 = ...,

m $level/b.1.2,

write,

!

select level 1,

ds $v1 = ...,

m $level/b.1,

write,

...

select level 1,

filter $level/1,

t #1 = $v1 * $v2,

select level 2,

filter $level/2,

t #2 = $v2 * $v3,

t #3 = $v1 * $v3,

Here, the compiler would fault table #3, as variable V1 is only available at level 1, not at level 2. Note that this facility only provides a means for you to check the integrity of CL scripts - it takes effect only at compilation, and has no wider implications.