Chapter Contents

Previous

Next

Repairing Damaged Files

The base 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, which is available starting with Version 7.

Note:   SAS is unable to repair or recover a 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 data set option or system option DLDMGACTION=. 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 the 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 abort 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=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 requestor window 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:        V8                                     Indexes:              0
             Created:       12:39 Monday, January 4, 1999          Observation Length:   32
             Last Modified: 11:30 Tuesday, January 5, 1999         Deleted Observations: 0
             Protection:                                           Compressed:           NO
             Data Set Type:                                        Sorted:               NO
             Label:


                              -----Engine/Host Dependent Information-----

   Data Set Page Size:         8192
   Number of Data Set Pages:   1
   First Data Page:            1
   Max Obs per Page:           254
   Obs in First Data Page:     27
   Number of Data Set Repairs: 1                                             
   Last Repair:                12:46 Tuesday, January 5, 1999

                        


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 explicitly using the PROC DATASETS INDEX CREATE statement.


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 system option DLDMGACTION=. 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 may 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 abort 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 requestor window 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 damaged log is not maintained for a catalog.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.