Language Reference


ROW Function

ROW (x);

The ROW function is part of the IMLMLIB library . The ROW function returns a matrix that has the same dimensions as the x matrix and whose ith row has the value i. You can use the ROW and COL function to extract elements of a matrix. See the COL function for an example.

You can also use the ROW function to generate an ID variable when you convert data from a wide format to a long format. For example, the following statements show how to generate a column vector that has values $\{ 1, 1, 1, 2, 2, 2, \ldots , 5, 5, 5\} $:

NumSubjects = 5;        /* number of subjects */
NumRepeated = 3;        /* number of repeated obs per subject */
Z = row(j(NumSubjects, NumRepeated));
Subj = shape(Z, 0, 1);  /* {1, 1, 1, 2, 2, 2, ..., 5, 5, 5}   */