Sample 24629: Dynamically determine if an audit trail exists for a SAS® data set
Use the EXIST function with the AUDIT parameter to determine if a SAS data set has an audit trail defined.
Note: The AUDIT parameter to the EXIST function is available beginning with SAS® 9.1.
Additionally, this sample has extra logic using new ATTRN function parameters (available in SAS 9.1) to return information about an existing audit trail.
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.
data test;
a=100;
b=50;
c=10;
run;
proc datasets lib=work nolist;
audit test;
initiate;
quit;
data none;
x=1;
y=40;
run;
/* EXIST returns 1 if the library member exists, or 0 if */
/* member-name does not exist or member-type is invalid. */
data _null_;
rc=exist('work.test','audit');
put 'work.test with audit trail ' rc=;
rc=exist('work.none','audit');
put 'work.none without audit trail ' rc=;
/* Open WORK.TEST */
dsid=open("work.test");
/* AUDIT specifies whether logging to an audit file is enabled */
a=attrn(dsid,"audit");
/* AUDIT_DATA specifies whether after-update record images are stored */
a_d=attrn(dsid,"audit_data");
/* AUDIT_BEFORE specifies whether before-update record images are stored */
a_b=attrn(dsid,"audit_before");
/* AUDIT_ERROR specifies whether unsuccessful after-update record */
/* images are stored */
a_e=attrn(dsid,"audit_error");
put 'Using the ATTRN function '/ a= / a_d= / a_b= / a_e= ;
/* Close WORK.TEST */
dsid=close(dsid);
run;
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.
OUTPUT to SAS log
work.test with audit trail rc=1
work.none without audit trail rc=0
Using the ATTRN function
a=1
a_d=1
a_b=1
a_e=1
Use the EXIST function with the AUDIT parameter to determine if a SAS data set has an audit trail defined.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step Common Programming Tasks ==> Utilities
|
| Date Modified: | 2005-12-08 11:34:13 |
| Date Created: | 2004-09-30 14:08:59 |
Operating System and Release Information
| SAS System | Base SAS | Tru64 UNIX | 9.1 TS1M0 | n/a |
| OpenVMS Alpha | 9.1 TS1M0 | n/a |
| HP-UX IPF | 9.1 TS1M0 | n/a |
| Linux | 9.1 TS1M0 | n/a |
| 64-bit Enabled Solaris | 9.1 TS1M0 | n/a |
| 64-bit Enabled HP-UX | 9.1 TS1M0 | n/a |
| 64-bit Enabled AIX | 9.1 TS1M0 | n/a |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | n/a |
| z/OS | 9.1 TS1M0 | n/a |