Language Reference

ROW Function

ROW (x) ;

This function is supported by the IML procedure and the iml action.

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 StartSet 1 comma 1 comma 1 comma 2 comma 2 comma 2 comma ellipsis comma 5 comma 5 comma 5 EndSet:

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}   */
Last updated: April 16, 2021