|SAS/AF Software: Class Dictionary|
|Commands for the Data Set Model Class|
The following commands are supported by the Data Set Model class through the _execCmd method. Note that SCL programs should use the method that corresponds to the command; commands are provided for interactive use by end-users.
This command returns an error when the access method used to read the table does not support access by absolute row number or when a WHERE clause is in effect.
This command corresponds to the method _gotoAbsoluteRow.
Note: The ADD
command is not allowed when browsing a table or if the NOADD option is specified.
By default, all values in a new row are missing. If an initial value has been stored for the column, the value for a new row contains the initial value for the column. If no WHERE clause or key is specified, the new row becomes the current row if the engine supports this behavior.
This command corresponds to the method _addRow.
To check the current autosave parameter value, issue the AUTOSAVE command without specifying an n value.
Regardless of the AUTOSAVE parameter value, you can save the table at any time by using the SAVE command.
This command corresponds to methods: _getAutosave, _save, and _setAutosave.
The CREATE command will write the rows to the table in the same order they were read by the engine. For example, if a WHERE clause or _setKey method has been applied, only those rows meeting the WHERE clause or set key condition are written to the table.
You can select which columns are included in the new table in the following ways:
You can add a list of table options following the table name. The list must be enclosed in parentheses.
By default, the CREATE command fails with an error message if the named table already exists. Specify the REPLACE option if you want the new table to replace an existing table with the same name. If you use the REPLACE option, it must come before the column name arguments.
This command corresponds to the _saveAs method.
The DELETE command is an editing command and is not valid when browsing a table.
Note: The DELETE command is not allowed if
the NODELETE option is specified.
In record-level locking, the DELETE command deletes only the currently locked row in the table.
In member-level locking, you can delete one or more rows at a time. To delete a single row, follow the DELETE command with the row number for the row to be deleted. If you are currently editing a row, issuing the DELETE command deletes that row.
To delete multiple rows, follow the DELETE command with a list of row numbers. Separate the row numbers with at least one space. For example, issue the following command to delete rows 5 and 10:
delete 5 10
To delete a range of rows, specify the first and last row numbers of the range, separated by a dash. For example, the following command deletes all rows between 5 and 10, inclusive:
This command corresponds to the method _deleteRow.
Note: The DUP command is not allowed when browsing a table or if the
NOADD option is specified.
By default, the current row is duplicated once. To duplicate the same row again, issue the DUP command again. Alternatively, you can follow the DUP command with the desired number of copies. For example, the following command duplicates the current row three times:
In member-level locking, the DUP command copies the specified row n times and adds the new rows to the table. If no row is specified, the current row is used. You can select the row to copy by supplying its number as the row argument in the DUP command. To specify the row argument, you must also specify the n argument (the number of times you want the row duplicated). For example, the following command duplicates row 5 two times:
dup 2 5
This command corresponds to the method _copyRow.
This command corresponds to the method _findRow.
If the last FIND or RFIND command reached the end of the table without a match, the search begins at the beginning of the table.
This command corresponds to the method _repeatFindRow.
This command corresponds to the method _save.
The SORT command is not valid in browse mode unless you specify an output data set.
You can specify sort options to be used for the sort depending on your operating system. All sort options must be preceded by a slash (/). See the _sort method for a list of the sort options.
The UPDATE command is not allowed when the BRONLY option has been specified.
The table can be opened for editing with a control level of either RECORD or MEMBER. If you do not use either argument, the default control level used is the control level specified in the attribute window of the attached viewer or in the CNTLLEV data set option (if one is specified).
When the table is opened for editing, you can use the UPDATE command to change the current control level for the table by specifying the parameter.
The UPDATE command fails if the specified control level would cause a locking conflict. For example, you cannot specify UPDATE MEMBER if the table is open with a control level of RECORD in another window or SAS session.
This command corresponds to the method _setOpenmode.
The complete set of conditions is called a temporary WHERE clause. The conditions can be modified or canceled during the lifetime of the object. In contrast, the WHERE option (specified in the ATTRIBUTE window) defines a permanent WHERE clause that cannot be changed or canceled during the FRAME session and which is not affected by WHERE commands.
The WHERE command has several forms:
WHERE expression applies the conditions specified in the expression as the new temporary WHERE clause, replacing any clause previously in effect.
WHERE ALSO expression adds the conditions specified in the expression to the existing temporary WHERE clause.
WHERE UNDO deletes the most recently added set of conditions from the temporary WHERE clause.
WHERE | WHERE CLEAR cancels the current temporary WHERE clause.
If you use the ADD or DUP command to add a new row and enter values that do not meet the WHERE conditions, the row cannot be edited once you go to a new row.
The WHERE command cannot be used in conjunction with the _setKey method.
This command corresponds to the method _setWhere.
The Data Set Model class supports the column attributes shown in Table 1.
Note: You cannot change the NAME, TYPE, or LENGTH of a column.
|'NAME'||C||the name of the column:
must be 32 or fewer characters in length,
must be a valid SAS name or nliteral if validvarname option is specified
|'TYPE'||C||the type of the column:
'C' for character columns
'N' for numeric columns
|'LENGTH'||N||the data length for the column:
for character items, the maximum length is 32K
for numeric items, the maximum length is 8
|'FORMAT'||C||the format name for the column:
must be appropriate for the type of the column
|'INFORMAT'||C||the informat name for the column:
must be appropriate for the type of the column
|'LABEL'||C||the label for the column:
may be a maximum of 256 characters
|'INITVALUE'||C|N||the initial value to use for the column when adding new records to the table. The type is the same as the data column.|
|'DSPROTECTD||C||indicates whether the column values are derived via SQL. Valid values are 'Y' | 'N'.|
|Data Set Model Attributes|
The Data Set Model class supports the following data set attributes:
|'NAME'||C||the name of the open table, if any|
|'MEMBER_TYPE'||C||the member type for the table, for example, DATA or VIEW|
|'ENGINE'||C||the name of the engine used for the table|
|'CREATE_DATE'||N||the creation date of the table as a datetime value|
|'MODIFY_DATE'||N||the last modified date of the table as a datetime value|
|'PROTECTION'||C||the level of password protection on the table: READ, WRITE, or ALTER|
|'TYPE'||C||the type for the displayed table|
|'OPENMODE'||C||the open mode for the table: EDIT or BROWSE|
|'LOCK_LEVEL'||C||the locking level for the table: RECORD or MEMBER|
|'LABEL'||C||the label for the table|
|'NUMBER_OF_ROWS'||N||the number of logical rows in the table, if known (those not marked for deletion). It returns -1 if unknown.|
|'NUMBER_OF_COLUMNS'||N||the number of columns in the table|
|'INDEXES'||N||the index status of the table:|
|1 the table is indexed|
|0 the table is not indexed|
|'NUMBER_OF_DELETEDROWS'||N||the number of deleted rows in the table|
|'COMPRESSED'||C||the type of compression used for the table|
|'SORTED'||N||the sort status of the table:|
|1 the table is sorted|
|0 the table is not sorted|
|N||the identifier of an SCL list that contains character items for each column in the table|
|'WHERE_LIST'||N||the identifier of an SCL list that contains character items for any currently applied where clause|
|'OPTION_LIST'||N||the identifier of an SCL list that contains character items for the following data set model options: BRONLY, NOADD, and NODELETE|
|'LOCKED_ROW'||N||the relative row number of the row that is locked. If no row is locked, a value of -1 is returned.|
Top of Page
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.