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:

  • A system failure occurs while the data file or catalog is being updated.

  • Damage occurs to the storage device where a data file resides. In this case, you can restore the damaged data file, the index, and the audit file from a backup device.

  • 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.

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.

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.

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 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.

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 38.1: Output of CONTENTS Procedure
start example
 The CONTENTS Procedure       Data Set Name      SASUSER.CENSUS                       Observations          27       Member Type        DATA                                 Variables             4       Engine             V9                                   Indexes               0       Created            10:06 Wednesday, January 22, 2003    Observation Length    32       Last Modified      10:06 Wednesday, January 22, 2003    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.0000A0       Host Created                WIN_NT                        Alphabetic List of Variables and Attributes                              #    Variable      Type    Len                              2    CrimeRate     Num     8                              1    Density       Num     8                              4    PostalCode    Char    2 
end example
 

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:

  • copying a SAS data file by some means other than PROC COPY or PROC DATASETS, for example, using a DATA step

  • using the FORCE option in the SORT procedure to write over the original data file.

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

  • localized damage is caused by a disk condition, which results in some data in memory not being flushed to disk. The catalog entries that are currently open for update are marked as damaged. Each damaged entry is checked to determine if all the records can be read without error.

  • severe damage is caused by a severe I/O error. The entire catalog is marked as damaged.

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.




SAS 9.1.3 Language Reference. Concepts
SAS 9.1.3 Language Reference: Concepts, Third Edition, Volumes 1 and 2
ISBN: 1590478401
EAN: 2147483647
Year: 2004
Pages: 258

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net