# Help System (web edition)

```Special forms of VARSTAT

VARSTAT <data>,Y,FIRST,L / L=val1,val2,...
finds the first occurrence of values listed by L in each record
and saves the position (# of variable) wherefrom the sought sequence
starts as variable Y. For example, if L=0,1,0,1 and we have a
record 1 1 0 1 1 0 1 0 1 1 0 0 1 0 1 1 1 ..., Y will be 6.

VARSTAT <data>,Y,LAST,L / L=val1,val2,...
respectively finds the last occurrence of a list of values. In the
example above Y would be 12.

Both in FIRST and LAST missing values in the list are notated by `-'s.
If the sequence of values given by L is not found at all in a certain
record, the code of a missing value is saved in Y.

Special forms of VARSTAT (continuation)

VARSTAT <data>,Y,#SEQ,L / L=val1,val2,...
finds the number of sequences of values listed by L in each record.
For example, if L=1,0,1 and we have a record
1 1 0 1 1 0 1 0 1 1 0 0 1 0 1 0 1 , Y will be 3.
^     ^               ^           <- starting positions of 1,0,1
If specification OVERLAP=1 is given, also overlapping sequences are counted.
In this case in the example
1 1 0 1 1 0 1 0 1 1 0 0 1 0 1 0 1   Y will be 5.
^     ^   ^           ^   ^

VARSTAT <data>,Y,#RUN,L / L=val1,val2,...
finds the number of runs of values listed by L in each record.
For example, if L=1,2 and we have a record
1 1 1 0 2 1 2 0 0 2 2 0 1 , Y will be 4
^       ^         ^     ^   <- starting positions of the runs

Special forms of VARSTAT (continuation)

VARSTAT <data>,Y,CYCLEN
computes the length of the shortest cycle of values which generates
the current record of active variables.

Example:
DATA C12,a,a+4,n,m
1 1 1 1 1 1 1 1 1 1 1 1 11
A B C D E F G H I J K L  X
1 2 5 1 2 5 1 2 5 1 2 5  3
4 7 4 7 4 7 4 7 4 7 4 7  2
9 9 9 9 9 9 9 9 9 9 9 9  1
1 2 3 4 1 2 1 2 3 4 1 2  6
1 2 1 2 1 2 1 2 1 2 1 1 12

VARSTAT C12,X,CYCLEN / gives cycle lengths of A,B,...,K,L  as X

Special forms of VARSTAT (continuation)

VARSTAT <data>,Y,#MODEVAL
computes # of values (frequency) of the most common value in
the current record.

For example, in the case
1 3 2 3 2 2 1 1 3 3 3 3
#MODEVAL gives 6 since the mode (3) has 6 occurrences.