Sample 43637: Check to see whether an index exists
The sample code on the Full Code tab checks a SAS data set to see whether an index exists and writes the appropriate response to the SAS log.
To understand more about the functions used in this sample, please refer to the documentation about functions at the links below.
Functions and Call Routines by Category for SAS 9.1.3
Functions Syntax by Category for SAS 9.2
See sample 43456 for a related note about SAS indexes.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This writes the correct message to the log to let the user know whether there is an index associated with the SAS data set.
%macro index_exist(dsn);
%let dsid=%sysfunc(open(&dsn));
%let indx=%sysfunc(attrn(&dsid,isindex));
%if &indx=0 %then %put there is no index;
%else %put there is an index;
%let rc=%sysfunc(close(&dsid));
%mend index_exist;
%index_exist(sashelp.class)
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
1918 %macro index_exist(dsn);
1919 %let dsid=%sysfunc(open(&dsn));
1920 %let indx=%sysfunc(attrn(&dsid,isindex));
1921 %if &indx=0 %then %put there is no index;
1922 %else %put there is an index;
1923 %let rc=%sysfunc(close(&dsid));
1924 %mend index_exist;
1925 %index_exist(sashelp.class)
there is no index
The sample uses SAS® I/O functions to see whether a data set has an index.
Type: | Sample |
Topic: | SAS Reference ==> Functions ==> SAS File I/O ==> ATTRN SAS Reference ==> Functions ==> SAS File I/O ==> CLOSE SAS Reference ==> Functions ==> SAS File I/O ==> OPEN
|
Date Modified: | 2011-07-01 14:40:55 |
Date Created: | 2011-07-01 10:38:33 |
Operating System and Release Information
SAS System | Base SAS | Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
OpenVMS VAX | | |
z/OS | | |
Z64 | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft® Windows® for x64 | | |
OS/2 | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2003 for x64 | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows Server 2008 for x64 | | |
Microsoft Windows XP Professional | | |
Windows 7 Enterprise 32 bit | | |
Windows 7 Enterprise x64 | | |
Windows 7 Home Premium 32 bit | | |
Windows 7 Home Premium x64 | | |
Windows 7 Professional 32 bit | | |
Windows 7 Professional x64 | | |
Windows 7 Ultimate 32 bit | | |
Windows 7 Ultimate x64 | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
Windows Vista for x64 | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
ABI+ for Intel Architecture | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |