You can copy data from the DataObject into a matrix by using the GetVarData method of the DataObject. For example, add the following statements to the SAS/IML Studio program from the previous section, and select → from the main menu.
dobjMatrix.GetVarData( "XVar", x); print x;
The result is a matrix x
that contains the values of the XVar
variable. You can name the matrix anything you want. It can have the same name as the variable in the DataObject (as the
z
variable and matrix did) or a completely different name (as in this example). After the data are copied into a matrix, there
is no linkage between the DataObject and the matrix: changing elements of the matrix does not affect the DataObject, and changing
the DataObject does not affect the matrix.
The CopyServerDataToDataObject module uses this approach to read variables in a server data set directly into a DataObject. This module is discussed in Chapter 5: Adding Variables to the DataObject. Again, the number of observations in the server data set must match the number of observations in the DataObject.