Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the Data Set Model Class


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.

n
scrolls the display to the absolute row referenced by the command. If the n value is greater than the number of rows in the table, the last row in the table is displayed.

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.

ADD
adds a new row to the table.

Note:   The ADD command is not allowed when browsing a table or if the NOADD option is specified.  [cautionend]

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.

AUTOSAVE <n>
specifies how frequently the model automatically saves the table. The autosave value determines how many rows must be modified before an automatic save is performed. By default, the table is saved automatically whenever 25 rows have been modified since the last save.

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.

CREATE table <REPLACE> <WITH <ALL | column-list>>
creates a new SAS table using some or all of the columns from the current table. The new table duplicates both the structure and contents of the current table.

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.

DELETE <row < ...row-n>>
deletes one or more rows in the table.

The DELETE command is an editing command and is not valid when browsing a table.

CAUTION:
Deletions cannot be recovered. You cannot recover the contents of a deleted row.  [cautionend]

Note:   The DELETE command is not allowed if the NODELETE option is specified.  [cautionend]

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:







delete 5-10

This command corresponds to the method _deleteRow.

DUP <n < row>>
copies the current row (in record-level locking). The newly copied row is immediately added to the table, and it becomes the current row if the engine supports this behavior. If you copy multiple rows simultaneously, the last row copied becomes the current row if the engine supports this behavior.

Note:   The DUP command is not allowed when browsing a table or if the NOADD option is specified.  [cautionend]

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:







dup 3

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.

FIND find-request
finds the next row (beginning at the current row, or at row 1 if there is no current row) that meets the specified find-request.

This command corresponds to the method _findRow.

RFIND
finds the next row that meets the find-request that was previously specified on a FIND command.

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.

SAVE
stores all changes made to the table since the last time it was saved. See also the AUTOSAVE command.

This command corresponds to the method _save.

SORT <ASCENDING | DESCENDING> column </options>
sorts the table by the specified columns, and if no output table is specified, the table is sorted in place. Multiple columns can be specified. The SORT command uses the sorting program that SAS supports for your operating system. If multiple columns are specified, the table is sorted by those columns in the order in which they are specified.

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.

UPDATE <RECORD | MEMBER>
changes the model from browsing to editing, or changes the control level of the model when already open for editing by specifying the argument.

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.

WHERE <<ALSO>expression> | <UNDO|CLEAR>
imposes one or more sets of conditions that rows in the table must meet in order to be read. Expression is any valid SAS expression involving one or more of the columns in the table. Rows that do not satisfy the specified conditions cannot be edited.

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.


Column Attributes

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.   [cautionend]

Column Attribute Items
Item Type Description
'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:

Data Set Attribute Items
List item Type Description
'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
'COLUMN_LIST'

('VARIABLE_LIST')

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.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.