UNSTACK procedure
Splits vectors into individual vectors according to levels of a factor (R.W. Payne).
Options
Parameters
Description
UNSTACK allows you to split up (or unstack) vectors into individual vectors. The contents of the individual vectors are determined by a factor, specified by the DATASET option. In the simplest case, each original (stacked) vector is split into several new (unstacked) vectors, one for each level of DATASET. The process assumes that the sets are "replicate" sets of data. For example DATASET might correspond to days on which identical sampling schemes were followed. In the most straightforward case, each set contains the same number of observations all stored in an identical order. However, if the observations are in different orders or if some are absent in some of the sets, you can use the IDSTACKED option to specify one or more factors to identify the matching observations within the sets. The IDUNSTACKED option then allows you to save new factors to indicate where the observations are stored in the new (unstacked) vectors. The unstacked vectors are all of the same length, and missing values are inserted for absent observations.
There are three parameters. STACKEDVECTOR lists the vectors (variates, factors or texts) that are to be split up. DATASETINDEX specifies a level of the DATASET factor for each member of the STACKEDVECTOR list, and UNSTACKEDVECTOR specifies a new vector to store the units of the STACKEDVECTOR corresponding to that DATASETINDEX. So, for example
UNSTACK [DATASET=Days] 5(Weight,Height);\
DATASETINDEX=1,2,3,4,5;\
UNSTACKEDVECTOR=W1,W2,W3,W4,W5,H1,H2,H3,H4,H5
would put the weight measurements made on days 1-5 into W1, W2, W3, W4 and W5, respectively, and the height measurements into H1, H2, H3, H4 and H5. (The construct 5(Weight,Height) is equivalent to typing Weight five times and then Day five times, and the DATASETINDEX list 1,2,3,4,5 is repeated twice so that it matches the lengths of the other parameter lists.) This method of specification means that you are free to list the vectors and levels in whatever order is most convenient. For example
UNSTACK [DATASET=Days] (Weight,Height)5;\
DATASETINDEX=2(1,2,3,4,5);\
UNSTACKEDVECTOR=W1,H1,W2,H2,W3,H3,W4,H4,W5,H5
lists them in group order rather one stacked vector at a time. If DATASETINDEX is not specified, the levels of DATASET are taken in order one at a time (and recycled if necessary).
Option: DATASET, IDSTACKED, IDUNSTACKED.
Parameter: STACKEDVECTOR, DATASETINDEX, UNSTACKEDVECTOR.
Method
The vectors are unstacked using the standard GenStat manipulation commands, including SUBSET and EQUATE.
Action with
RESTRICT
Any restrictions on the vectors are ignored.