Chapter Contents |
Previous |
Next |
OPEN |
Category: | SAS Table |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
table-id=OPEN(<table-name<>,mode>); |
Type: Numeric
All SAS data set options are valid except the FIRSTOBS= and OBS= options, which are ignored.
Type: Character
'I' |
an INPUT mode in which values can be read but cannot be modified. (This is the default.) Rows are read in random order. |
'IN' |
an INPUT mode in which rows can be read sequentially and can also be revisited. |
'IS' |
an INPUT mode in which rows can be read sequentially but cannot be revisited. |
'N' |
NEW mode, which creates a new table. If table-name already exists, the table is replaced without warning. |
'U' |
an UPDATE mode in which values in the table can be modified and rows can be read in random order. |
'UN' |
an UPDATE mode in which values in the table can be modified, rows can be read sequentially, and rows can be revisited. |
'US' |
an UPDATE mode in which values in the table can be modified and rows can be read sequentially. However, rows cannot be revisited. |
'V' |
UTILITY mode, which must be used in order to change any column attributes or to manipulate any associated table indexes. |
Type: Character
Details |
OPEN opens a SAS table or a SAS/ACCESS view descriptor and returns a unique numeric table identifier, which is used in most other SCL functions that manipulate tables.
If mode is I or U , then OPEN defaults to the strongest access mode available in the engine. That is, if the engine supports random access, OPEN defaults to random access. Otherwise, the file is opened in IN or UN mode automatically. Files are opened with sequential access, and a system level warning is set. For example, opening a DB2 SAS/ACCESS view descriptor in INPUT (I) mode opens the file but produces the warning "This task requires reading rows in a random order, but the engine allows only sequential access." To enable the file to be read multiple times and to prevent this warning, use an open mode of IN instead.
Note that both IS and IN (as well as US and UN ) refer to sequential access. However, IN allows revisiting a row, whereas IS does not.
Note: If sequential access is
too restrictive but random access is too slow, try specifying the TOBSONO=
data set option. See SAS Language Reference: Dictionary for more information.
By default,
a SAS table is opened with a control level of RECORD. See SAS Language Reference: Dictionary
for details about the CNTLLEV (control level) SAS data set option.
A table that is already opened can be opened again, subject to the following restrictions:
A table that is already open in any mode can be opened again in NEW mode, because that replaces everything in the old table.
An open SAS table should be closed when it is no longer needed.
Example |
Open the table PRICES in the library MASTER, using INPUT mode:
tableid=open('master.prices','i'); if (tableid=0) then _msg_=sysmsg(); else _msg_='PRICES table has been opened';
You can pass values from SCL variables to be used in data set options. Open the table MYDATA, and use the WHERE= data set option to apply a permanent WHERE clause, using the value from the numeric variable SCRNUM:
tableid= open('mydata(where=(num='||put(scrnum,5.)||'))');
Open the table MYDATA, and use the WHERE= data set option to apply a permanent WHERE clause, using the value from the character variable SCRNAME:
tableid= open('mydata(where=(name='||quote(scrname)||'))');
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.