Chapter Contents

Previous

Next
DSID

DSID



Searches for a SAS table name and returns the table identifier

Category: SAS Table


Syntax
Details
Examples
Example 1: Working with Several Tables
Example 2: Returning the DSID of a Generation Data Set
See Also

Syntax

dsid=DSID(<table-name<,mode<,nth<,gen-num>>>>);

dsid
contains either the identifier for the table, or
0 if the table is not currently open, if the table is not open in the requested mode, or if no nth open occurrence exists.
<0 if an error occurs. SYSMSG contains the error text.

Type: Numeric

table-name
names the SAS table to search for. The default is _LAST_, which is the last table that was created in the current SAS session. A one-level name is assumed to be a SAS table name in the default SAS data library, WORK. A two-level name is assumed to be libref.table.

Type: Character

mode
specifies whether to limit the search to tables that are open in one of the modes listed below. If mode is not specified, DSID returns the dsid for the first occurrence of table-name that is open in any mode. Values for mode are
'I' INPUT mode, allows random access if the engine supports it; otherwise, defaults to IN mode.
'IN' INPUT mode, reads sequentially and allows revisiting rows.
'IS' INPUT mode, reads sequentially but does not allow revisiting rows.
'N' NEW mode, creates a new SAS table.
'U' UPDATE mode, allows random access if the engine supports it; otherwise, defaults to UN mode.
'UN' UPDATE mode, reads sequentially and allows revisiting rows.
'US' UPDATE mode, reads sequentially but does not allow revisiting rows.
'V' UTILITY mode, allows modification of column attributes and indexes that are associated with the SAS table.
For more information about open modes, see OPEN.

Type: Character

nth
specifies which occurrence of table-name opened in the specified mode to search for. By default, the search returns the first occurrence.

Type: Numeric

gen-num
is the generation number of the SAS table for which the DSID is returned.

Type: Numeric


Details

DSID searches all SAS tables that are currently open. This function is useful for accessing table identifiers across entries.


Examples

Example 1: Working with Several Tables

Open several SAS tables and find the first occurrence in various modes:

/* Open several SAS tables, varying the open mode */
dsid1 = open('sasuser.class', 'I');
dsid2 = open('sasuser.class', 'U');
dsid3 = open('sasuser.class', 'U');
dsid4 = open('sasuser.houses', 'U');
dsid5 = open('sasuser.class', 'I');
dsid6 = open('sasuser.houses', 'U');
dsid7 = open('sasuser.houses', 'I');
dsid8 = open('sasuser.class', 'U');

 /* Find the first occurrence open in any mode.*/
first = DSID( 'sasuser.houses' );
put first=;

 /* Find the first occurrence open in 'I' */
firstI = DSID( 'sasuser.houses', 'I' );
put firstI=;

 /* Find the second occurrence open in 'I' */
secondI = DSID( 'sasuser.class', 'I', 2 );
put second=;

 /* Return the fourth occurrence open in 'U' */
secondU = DSID( 'sasuser.class', 'U', 4 );
put secondU=;
This example produces the following output:
first=4
firstI=7
secondI=5
secondU=0

Example 2: Returning the DSID of a Generation Data Set

The following code returns the DSID of the SAS table WORK.ONE#003.

dsid=DSID(`work.one',`IN',1,3);

See Also

OPEN


Chapter Contents

Previous

Next

Top of Page

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