SAS Component Language Dictionary |
Category: | SAS Table |
Syntax |
rc=EXIST(member-name<,member-type<,generation>> ); |
contains the return code for the operation:
1 | |
0 |
Either member-name does not exist or member-type is invalid. |
is the generation number of the SAS table whose existence you are checking. If member-type is not DATA, generation is ignored.
Details |
If member-name is not specified, EXIST verifies the existence of the member specified by the system variable _LAST_. If member-type contains an invalid value, EXIST returns the value 0.
Examples |
Call the FSEDIT function only if the SAS table specified in the variable TABLENAME exists. If the table does not exist, display a message on the message line.
if (exist(tablename)) then call fsedit(tablename); else _msg_='Table '||tablename||' does not exist.';
Verify the existence of the SAS table view TEST.MYVIEW:
rc=exist('test.myview','view');
Determine if the third generation of the data set work.one exists:
rc=exist('work.one','data',3);
You can query for the existence of an audit trail file via the EXIST function. An audit trail file is an optional SAS file that can be created to log changes to SAS data. To test the EXIST function, follow these steps:
Create a data set with an audit file by entering the following code in the SAS Editor and then submitting it:
data sasuser.class; set sashelp.class; run; proc datasets lib=sasuser; audit class; initiate; quit;
Test for the existence of the audit file by entering the following code in an SCL file:
INIT: hasAudit=exist('sasuser.class','AUDIT'); put hasAudit=; return;
When you compile and then execute the SCL code, the SAS log displays 'hasAudit=1', indicating that the audit file exists.
Now delete SASUSER.CLASS and then recreated it without an audit file by entering and then submitting in the SAS Editor the following DATA step:
data sasuser.class; set sashelp.class; run;
When you execute the SCL code from step 2 , the SAS log displays 'hasAudit=0' (indicating that the audit file does not exist).
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.