Language Reference

TABLEWRITETODATASET Call

CALL TABLEWRITETODATASET (table, member) ;

CALL TABLEWRITETODATASET (table, libref, member) ;

CALL TABLEWRITETODATASET (table, libref, member, dsOptions) ;

This subroutine is supported only by the IML procedure.

The TableWriteToDataSet subroutine creates a SAS data set from a table. Each column in the table becomes a new variable in the data set.

The subroutine takes the following input arguments. The first argument is a table; the other arguments are character strings.

table

specifies an existing table.

libref

specifies the name of a SAS libref. If this argument is omitted, the default libref is used. You can use the DEFLIB= option in the RESET statement to specify the default libref.

member

specifies the name of a SAS data set.

dsOptions

specifies data set options, such as DROP=, KEEP=, and WHERE= options.

The subroutine creates a data set. The location of the data set is determined by the value of the libref argument; the name of the data set is determined by the value of the member argument. If you do not specify the dsOptions argument, the data set contains all the variables and all the observations in the member data set.

The following program creates a table from the Sashelp.Class data set. The table is written to the default libref, which is usually Work. A second call to the TableWriteToDataSet subroutine writes a subset of the data to Work.Boys.

tbl = TableCreateFromDataSet("Sashelp", "Class");

call TableWriteToDataSet(tbl, "Class");  /* write to default libref */
dsOpt = "drop=Weight where=(Sex='M')";
call TableWriteToDataSet(tbl, "work", "Boys", dsOpt); /* work.Boys */
Last updated: April 11, 2025