How to recover damaged SAS Data set (using PROC DATASETS REPAIR)

You might have encountered the following error when loading, updating to re-creating a sas data set. 

  • “File WORK.XXXX.DATA is damaged. I/O processing did not complete”
  • ERROR: File OLRSAS.RESULT.DATA is damaged. I/O processing did not complete.

This is a most common situation where you need to repair a damaged data set:

  1. A system failure occurs while updating a sas dataset or catalog.
  2. An I/O (Input/Output) error occurs while writing to sas data set or catalog. 
  3. If the disk gets full while updating sas data set being stored.

Recover SAS Data set using PROC DATASET REPAIR Statement

You can repair damaged dataset by using proc datasets repair statements. It is very effective as you don’t need to re-initiate the entire loading or updating process.

In fact you can manually run proc datasets repair statements on that particular target table to solve this error.

Syntax:

proc datasets library=mylib;

   repair mydata;

run;

Recover damaged Indexes

Indexes can become damaged for the same reason who saw earlier as sas dataset gets damaged. Use PROC DATASETS REPAIR statement to repair damaged indexes. It works like a charm.

We have already seen how to create indexes on SAS datasets in 4 different ways. For the demonstration purpose, let me create a new table (myLib.temp_zipcode) with a simple index (named ZIP) on it.

Let’s assume that index or that table itself gets damaged due to any of the reasons listed above and you saw the following error while updating that data set.

“ERROR: File myLib.TEMP_ZIPCODE.DATA is damaged. I/O processing did not complete.”

data myLib.temp_zipcode (index=(ZIP));
   set sashelp.ZIPCODE;
run;

proc contents data=myLib.temp_zipcode; quit;

Example to repair damaged data set: 

This example repairs a damaged data set, myLib.temp_zipcode, and re-creates its available indexes.Please note that myLib is a permanent SAS library. 

proc datasets library=myLib;

   repair temp_zipcode;

run;
repair damaged dataset (or index) using PROC DATASETS REPAIR Statement

Special case with WORK data set:

If you’re creating a work data set and encounter a similar issue than proc datasets repair statement might not work. I have tested this on SAS Studio but got the following error.

proc datasets library=work;

   repair temp_zipcode;

run;
Repair damaged indexes in SAS using PROC DATASETS REPAIR Statement

FAQ

Why SAS Data set gets damaged?

A data set can be damaged due to system failure occurs while updating a data set or catalog. 

Another reason could be I/O error occurs while writing to sas data set or catalog. 

How to recover damaged data set in SAS?

The damaged SAS data set can be recovered using proc datasets repair statement.

 

You can use this code to repair damaged data set:

 

proc datasets library=myLib;
  repair table_name;
run;
How to recover damaged indexes in SAS?

The damaged indexes on sas data set can be recovered using proc datasets repair statement.

 

You can use this code to repair damaged indexes:

 

proc datasets library=myLib;
  repair table_name;
run;

Free SAS Course

Learn SAS Code — The only programming course available on the internet which you need to master Data Analytics, Business Intelligence (BI) and Cloud technology.

100% free.

Unlock Free SAS Tutorials