Previous Page | Next Page

SAS File Management

Repairing Damaged 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:

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.

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 recreate it.  [cautionend]

Note:   If the audit file for a SAS data file becomes damaged, you will not be able to 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.  [cautionend]


Recovering SAS Data Files

To determine the type of action SAS will take 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 will automatically respond based on your specification as follows:

DLDMGACTION=FAIL

tells SAS to stop the step without a prompt and issue an error message to the 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 log indicating that the request file is damaged, and end the SAS session.

DLDMGACTION=REPAIR

tells SAS to automatically repair the file and rebuild indexes, integrity constraints, and the audit file as well. If the repair is successful, a message is issued to the log indicating that the open and repair were successful. If the repair is unsuccessful, processing stops without a prompt and an error message is issued to the log indicating the requested file is damaged.

Note:   If the data file is large, the time needed to repair it can be long.  [cautionend]

DLDMGACTION=NOINDEX

tells SAS to automatically repair the data file, disable the indexes and integrity constraints, delete the index file, update the data file to reflect the disabled indexes and integrity constraints, and limit the data file to be opened only in INPUT mode. A warning is written to the SAS log instructing you to execute the PROC DATASETS REBUILD statement to correct the disabled indexes and integrity constraints and rebuild the index file. For more information, see Recovering Disabled Indexes and Integrity Constraints.

DLDMGACTION=PROMPT

tells SAS to provide the same behavior that exists in Version 6 for both interactive mode and batch mode. For interactive mode, SAS displays a dialog box that asks you to select the FAIL, ABORT, or REPAIR action. For batch mode, the files fail to open.

For a data file, the date and time of the last repair and a count of the total number of repairs is automatically maintained. To display the damage log, use PROC CONTENTS as shown below:

proc contents data=sasuser.census;
run;

Output of CONTENTS Procedure

                                     The CONTENTS Procedure

       Data Set Name        SASUSER.CENSUS                       Observations          27
       Member Type          DATA                                 Variables             4
       Engine               V9                                   Indexes               0
       Created              10:06 Wednesday, January 24, 2007    Observation Length    32
       Last Modified        10:06 Wednesday, January 24, 2007    Deleted Observations  0
       Protection                                                Compressed            NO
       Data Set Type                                             Sorted                NO
       Label
       Data Representation  WINDOWS
       Encoding             wlatin1  Western (Windows)


                               Engine/Host Dependent Information

          Data Set Page Size          4096
          Number of Data Set Pages    1
          First Data Page             1
          Max Obs per Page            126
          Obs in First Data Page      27
          Number of Data Set Repairs  0
          File Name                   c:\winnt\profiles\sasxxx\sasuser\census.sas7bdat
          Release Created             9.2000A0
          Host Created                XP_PRO

                           Alphabetic List of Variables and Attributes

                                 #    Variable      Type    Len

                                 2    CrimeRate     Num       8
                                 1    Density       Num       8
                                 4    PostalCode    Char      2

Recovering Indexes

In addition to the failures listed earlier, you can damage the indexes for SAS data files by using an operating environment command to delete, copy, or rename a SAS data file, but not its associated index file. The index is repaired similarly to the DLDMGACTION= option as described for SAS data files, or you can use the REPAIR statement in PROC DATASETS to rebuild composite and simple indexes that were damaged.

You cannot use the REPAIR statement to recover indexes that were deleted by one of the following actions:

In the above cases, the index must be rebuilt using the PROC DATASETS INDEX CREATE statement.

Recovering Disabled Indexes and Integrity Constraints

When the DLDMGACTION=NOINDEX data set or system option is used and SAS encounters a damaged data file, SAS does the following:

The data file stays in INPUT mode until the PROC DATASETS REBUILD statement is executed. You use this statement to specify whether you want to restore the indexes and integrity constraints and rebuild the index file or delete the disabled integrity constraints and indexes. For more information, see the DATASETS Procedure REBUILD Statement in Base SAS Procedures Guide.

Recovering Catalogs

To determine the type of action that SAS will take when it tries to open a SAS catalog that is damaged, set the DLDMGACTION= data set option or system option. Then when a catalog is detected as damaged, SAS will automatically respond based on your specification.

Note:   There are two types of catalog damage:

  [cautionend]
DLDMGACTION=FAIL

tells SAS to stop the step without a prompt and issue an error message to the 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 catalog, you can issue the REPAIR statement in PROC DATASETS, which is documented in the SAS Procedures Guide. Note that when you use the REPAIR statement to restore a catalog, you receive a warning for entries that have possible damage. Entries that have been restored might not include updates that were not written to disk before the damage occurred.

DLDMGACTION=ABORT

tells SAS to terminate the step, issue an error message to the log indicating that the requested file is damaged, and end the SAS session.

DLDMGACTION=REPAIR

for localized damage, tells SAS to automatically check the catalog to see which entries are damaged. If there is an error reading an entry, the entry is copied. If an error occurs during the copy process, then the entry is automatically deleted. For severe damage, the entire catalog is copied to a new catalog.

DLDMGACTION=PROMPT

for localized damage, tells SAS to provide the same behavior that exists in Version 6 for both interactive mode and batch mode. For interactive mode, SAS displays a dialog box that asks you to select the FAIL, ABORT, or REPAIR action. For batch mode, the files fail to open. For severe damage, the entire catalog is copied to a new catalog.

Unlike data files, a damage log is not maintained for a catalog.

Previous Page | Next Page | Top of Page