DATA Step, Macro, Functions and more

Determine if SAS table is damaged?

Reply
Regular Contributor
Posts: 161

Determine if SAS table is damaged?

Hi,

Is there some way to define if some SAS table is demaged, without throwing error to the log?

Error looks like: 

ERROR: The open failed because library member ...is damaged.

Maybe some sas function or some filter on dictionary.tables etc.

Thanks!

Super User
Super User
Posts: 7,955

Re: Determine if SAS table is damaged?

Hi,

Some questions.  What were you running to get that error.  What SAS version, OS etc.  Have you tried re-starting SAS and trying again.  Only help page I could see was: 16086 - MODIFY may generate READ ACCESS VIOLATION and FILE libref.member.DATAIS DAMAGED messages

Regular Contributor
Posts: 161

Re: Determine if SAS table is damaged?

Hi Rw9,

I'm runing under aix, SAS 9.3.

Thanks for the link, will take a look.

Super User
Posts: 10,028

Re: Determine if SAS table is damaged?

You can use proc datasets to fix it . But as my experience , it is very little chance to fix it all.

libname x v9 'c:\temp';
data x.class;set sashelp.class;run;


proc datasets library=x;
repair class;
quit;

Xia Keshan

Super User
Posts: 10,028

Re: Determine if SAS table is damaged?

You can use proc datasets to fix it . But as my experience , it is very little chance to fix it all.

libname x v9 'c:\temp';
data x.class;set sashelp.class;run;


proc datasets library=x;
repair class;
quit;

Xia Keshan

Regular Contributor
Posts: 161

Re: Determine if SAS table is damaged?

Hi Ksharp,

I would like to have possibility just to get list of all demaged tables, for example from some library, I wouldn't repair them for now,  just collect all such data sets.

Thanks!

Super User
Posts: 10,028

Re: Determine if SAS table is damaged?

Oh. You could try OPEN() , if it return 0 then the table might be ruined .

Regular Contributor
Posts: 161

Re: Determine if SAS table is damaged?

Hi again,

I thought about that function but it returns 0 also in case if table does not exists physycally.

Maybe there is sence to combine open function with fexist, but again, if open func. return 0 and file exists phisically - is it right rule that define SAS demaged table?

Thanks!

Super User
Posts: 10,028

Re: Determine if SAS table is damaged?

you can select these exist tables from dictionary . like :

proc sql;

select memname from dictionary.members where libname='SASHELP' and memtype='DATA' ;

quit;

Regular Contributor
Posts: 161

Re: Determine if SAS table is damaged?

Hi again,

Yes, sure, so you propose such rule for separating demaged tables:

  1. Exists in dictionary(or sashelp)
  2. Open function returns 0

Ok, will rely on that for nowSmiley Happy

Thanks!

Regular Contributor
Posts: 161

Re: Determine if SAS table is damaged?

Looks like next simple condition define demaged tab:

     %let id=%sysfunc(open(&TableName));

           %if  %sysfunc(exist(&TableName)) & &id=0 %then %do;

          ...

                %let flag=damaged;

           %end;

           %else %do;

                %let rc=%sysfunc(close(&id));

           %end;

But after open dataset it should be closed, so it can be a little bit unsafe if that code will be run on production env., some tables can be needed in exact that moment for someone, maybe for insert/update etc.

As I know open function by default executes with "I" parameter, that is only for read, but still not sure if it will not impact somehow on another possible process on table.

Offcource lock can be done before but it's also bad idea to lock table even to miliseconds on production.

So if there is some way to define if table is demaged without open it- it would be great.

Generally I would like to define such tables without locking them and without puting error to the log.

Thanks!


Super User
Posts: 10,028

Re: Determine if SAS table is damaged?

contact sas Technical Support to see if they have a good solution.

Ask a Question
Discussion stats
  • 11 replies
  • 2085 views
  • 6 likes
  • 3 in conversation