SAS Component Language Dictionary |
Category: | SAS Table |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
table-id=OPEN(<table-name<>,mode>); |
contains the table identifier, or 0 if the table could not be opened.
is the SAS table or SAS/ACCESS view descriptor to open, specified as <libref.>member-name<(data-set-options)>. The default value for table-name is _LAST_, which is the last table created in the current SAS session. A one-level name is assumed to be USER.member-name.
All SAS data set options are valid except the FIRSTOBS= and OBS= options, which are ignored.
specifies the type of access to the table:
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 TOBSNO= 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:
If the table is already opened in UPDATE or INPUT mode, it cannot be opened again in UTILITY mode.
If the table is already opened in UTILITY mode (so that columns can be dropped, inserted, or changed), it can only be opened again in NEW mode.
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 |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.