Repairing Damaged SAS Files
Detecting Damage to SAS Files
The Base SAS engine detects possible damage to SAS data files (including indexes,
integrity constraints, and the audit file) and SAS catalogs and provides a means for
repairing some of the damage. If one of the following events occurs while you are
updating a SAS file, SAS can recover the file and repair some of the damage:
• A system failure occurs while the data file or catalog is being updated.
• The disk where the data file (including the index file and audit file) or catalog is
stored becomes full before the file is completely written to it.
• An input/output error occurs while writing to the data file, index file, audit file, or
catalog.
When the failure occurs, the observations or records that were not written to the data file
or catalog are lost and some of the information about where values are stored is
inconsistent. The next time SAS reads the file, it recognizes that the file's contents are
damaged and repairs it to the extent possible in accordance with the setting for the
DLDMGACTION= data set option or system option, unless the data set is truncated. In
this case, use the REPAIR statement to restore the data set.
If damage occurs to the storage device where a data file resides, you can restore the
damaged data file, the index, and the audit file from a backup device.
Note: SAS is unable to repair or recover a SAS view (a DATA step view, an SQL view,
or a SAS/ACCESS view) or a stored compiled DATA step program. If a SAS file of
type VIEW or PROGRAM is damaged, you must re-create it.
Note: If the audit file for a SAS data file becomes damaged, you cannot process the data
file until you terminate the audit trail. Then, you can initiate a new audit file or
process the data file without one.
Recovering SAS Data Files
To determine the type of action SAS takes when it tries to open a SAS data file that is
damaged, set the DLDMGACTION= data set option or system option. That is, when a
data file is detected as damaged, SAS automatically responds based on your
specification as follows:
DLDMGACTION=FAIL
tells SAS to stop the step without a prompt and issue an error message to the SAS
log indicating that the requested file is damaged. This specification gives the
application control over the repair decision and provides awareness that a problem
occurred.
To recover the damaged data file, you can issue the REPAIR statement in PROC
DATASETS, which is documented in Base SAS Procedures Guide.
DLDMGACTION=ABORT
tells SAS to terminate the step, issue an error message to the SAS log indicating that
the request file is damaged, and end the SAS session.
750 Chapter 36 • SAS File Management