Reading and Writing Data

Open a Server Data Set

If your data are stored in a SAS data library, such as Work, Sashelp, or Sasuser, or in a libref that you created using the LIBNAME statement, you can open the data by using a similar method. The method’s name is CreateFromServerDataSet. It is valid to have a LIBNAME statement in an IMLPlus program, so you can define your libref in the same program in which you use the CreateFromServerDataSet method.

Add the following statements at the bottom of the program window, and select ProgramRun from the main menu.

   declare DataObject dobjServer; 
   dobjServer = DataObject.CreateFromServerDataSet("Sashelp.CLASS"); 
   DataTable.Create( dobjServer ); 

Again, the data table might appear behind your program window, so move the program window if necessary. It is not necessary to create a DataTable unless you want to see a tabular view of the data.

If you already have a DataObject and you want to add variables from a server data set to it, then use the CopyServerDataToDataObject module as discussed in the section Use SAS/IML Matrices to Store Data and Chapter 5: Adding Variables to the DataObject.