SAS File Management |
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 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.
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:
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.
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.
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.
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.
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;
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:
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.
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:
automatically repairs the data file without the indexes and integrity constraints
disables the indexes and integrity constraints
deletes the index file
updates the data file to reflect the disabled indexes and integrity constraints
limits the data file to be opened only in INPUT mode
writes the following warning to the SAS log:
WARNING: SAS data file MYLIB.MYFILE.DATA was damaged and has been partially repaired. To complete the repair, execute the DATASETS procedure REBUILD 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 whether 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.
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.
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.
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.
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.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.