sas >> I am getting ERROR : Unable to clear or re-assign the library

by suhas.k.r » Tue, 17 Jun 2008 18:30:55 GMT

Hi all,

I am running my program in batch mode. I am calling user defined macro
twice in my code. I that macro i am assigning library ARDATA. Since i am
calling user defined macro twice in the same session i am this error for
library assignments.
First time when i am calling i have no problem. But when i call second
time i getting this error. Please any one can help me in this.

ERROR : Unable to clear or re-assign the library ARDATA because it is
still in use.

Cheers,
Suhas

sas >> I am getting ERROR : Unable to clear or re-assign the library

by Joep Steeman » Tue, 17 Jun 2008 20:15:24 GMT



You may want to implement a test for the existance of a libref.
Consider the next macro

%macro libref_exist(lib =, libpath =);
%if %sysfunc(libref(&lib)) %then %do;
%put libref &lib is not assigned, will be created;
%sysfunc(libname(&lib, &libpath));
%end;
%else %put libref &lib already assigned;
%mend libref_exist;

%libref_exist(lib=ardata, libpath = your_library); /*<<=== no quotes
here */


Regards, Joep

sas >> I am getting ERROR : Unable to clear or re-assign the library

by michaelraithel » Tue, 17 Jun 2008 20:37:09 GMT

Dear SAS-L-ers,

Suhas K R posted the following:

Suhas, well then I guess that some changes are in order. I would do
either one of these two things:

1. Move the LIBNAME out of the macro to a place where it is invoked
_BEFORE_ the macros are called. This may or may not be feasible, but it
is sure a low-tech solution.

2. Modify the macros to determine whether or not the LIBNAME was already
specified before proceeding:

%if (%sysfunc(libref(ARDATA))) %then %do;
LIBNAME ARDATA "C:\SUHAS\BIG\SASLIB";
%end;

The trick with #2 is to utilize the LIBREF function to test for the
existence of the ARDATA LIBREF. If it doesn't exist, then it is
assigned. If it does exist, then it is not reassigned.

Suhas, best of luck in all of your SAS endeavors!

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Michael A. Raithel
"The man who wrote the book on performance"
E-mail: XXXX@XXXXX.COM

Author: Tuning SAS Applications in the MVS Environment

Author: Tuning SAS Applications in the OS/390 and z/OS Environments,
Second Edition
http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=58172

Author: The Complete Guide to SAS Indexes

http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=60409

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Victorious warriors win first and then go to war, while defeated
warriors go to war first and then seek to win. - Sun-Tzu
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

sas >> I am getting ERROR : Unable to clear or re-assign the library

by HERMANS1 » Tue, 17 Jun 2008 20:53:15 GMT

Suhas:
In addition to the useful advice you have received from Joep and
Michael, I'll add that good programming practice includes closing what
you have opened when finished with it and reopening it when needed
again. In this case LIBNAME ARDATA; closes the LIBNAME reference.
S

-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of
Suhas K R
Sent: Tuesday, June 17, 2008 6:31 AM
To: XXXX@XXXXX.COM
Subject: I am getting ERROR : Unable to clear or re-assign the library
ARDATA because it is still in use.


Hi all,

I am running my program in batch mode. I am calling user defined macro
twice in my code. I that macro i am assigning library ARDATA. Since i am
calling user defined macro twice in the same session i am this error for
library assignments. First time when i am calling i have no problem. But
when i call second time i getting this error. Please any one can help me
in this.

ERROR : Unable to clear or re-assign the library ARDATA because it is
still in use.

Cheers,
Suhas

Similar Threads

1. library WORK may not be reassigned

2. Reassigning Work Library in V9.1.3 ??

Hi
I just upgraded to V9 and I need to change my work library from c: to
another drive, but when I search for the config file, I don't see
anything I recognise. I find the following 3 files:

    itconfig.exe
    config.tem
    sas.report.config.jar

can someone point me in the right direction here?

thanks in advance,

Machelle

3. how to control library permission if the library is assigned in autoexec

4. how to control library permission if the library is assigned

> From: z.chrysalis8
> Subject: how to control library permission if the library is
> assigned in autoexec
>
> I am having problem giving read/ write permission to a library in SMC.
> I gave read only access to a user for a library. But when the user
> login using EG, the user is able to read and write to the library. I
> suspect is because of the library assignment in autoexec file as when
> the library assignment is removed from autoexec, the permission given
> is working alright.
>
> The problem is the library assignment in autoexec is needed for other
> SAS programs. It would be troublesome to change this. Is there other
> workaround to control library permission with library assignment in
> autoexec?
>

that may be more trouble that it is worth

you will have to unassign the libref
and then reassign it with permissions:

libname library clear;
run;
libname library '<...>' <permissions>;

and the problem you will have are that the libref library contains
catalogs
that options refer to.

iirc it is (next to/nearly)
impossible to deallocate a libref
which contains a reference to compiled and stored macro catalogs
without jumping thru hoops.

Ron Fehd  the macro maven  CDC Atlanta GA USA RJF2 at cdc dot gov

5. Error in Proc Export (ERROR: Execute: Unable to insert row : )

6. Error in Proc Export (ERROR: Execute: Unable to insert row : )

Amar,

Sounds like the file already exists.  If you have the correct write
permission, you might succeed with including the REPLACE option.

HTH,
Art
-----------
On Feb 12, 2:39 am, Amar Mundankar < XXXX@XXXXX.COM > wrote:
> Hi all,
> While executing following code, I am getting error as :
> ERROR: Execute: Unable to insert row :
>
> What can be the reason????
>
> Below is the CODE and LOG.
>
> CODE:
>
> LIBNAME SD2 "G:\AppData\InfoOne_SAS\adhoc\IMP\CV\SASDATA";
> DATA TEST_PAY;
> SET SD2.FPR_ECS_DIST;
>  WHERE substr(DISTRICT,1,4)= '4Z17';
> RUN;
>
> PROC EXPORT DATA = TEST_PAY dbms=excel2000 OUTFILE = "\\tsclient\G
> \PUBLIC\! Warning - Files In This Directory are Deleted every 15 days
> \Sample\FPR_QC\ECSPAYDIST"; RUN;
>
> LOG:
> /*===============================================*/
> LIBNAME SD2 "G:\AppData\InfoOne_SAS\adhoc\IMP\CV\SASDATA";
> NOTE: Libref SD2 was successfully assigned as follows:
>       Engine:        V9
>       Physical Name: G:\AppData\InfoOne_SAS\adhoc\IMP\CV\SASDATA
> 2    DATA TEST_PAY;
> 3    SET SD2.FPR_ECS_DIST;
> NOTE: Data file SD2.FPR_ECS_DIST.DATA is in a format native to another
> host or the file encoding
>       does not match the session encoding. Cross Environment Data
> Access will be used, which may
>       require additional CPU resources and reduce performance.
> 4     WHERE substr(DISTRICT,1,4)= '4Z17';
> 5    RUN;
>
> NOTE: There were 122700 observations read from the data set
> SD2.FPR_ECS_DIST.
>       WHERE SUBSTR(DISTRICT, 1, 4)='4Z17';
> NOTE: The data set WORK.TEST_PAY has 122700 observations and 47
> variables.
> NOTE: DATA statement used (Total process time):
>       real time           40.21 seconds
>       cpu time            14.75 seconds
>
> 6
> 7    PROC EXPORT DATA = TEST_PAY dbms=excel2000 OUTFILE = "\\tsclient\G
> \PUBLIC\! Warning - Files
> 7  ! In This Directory are Deleted every 15 days\Sample\FPR_QC
> \ECSPAYDIST"; RUN;
>
> NOTE: New file "\\tsclient\G\PUBLIC\! Warning - Files In This
> Directory are Deleted every 15
>       days\Sample\FPR_QC\ECSPAYDIST.XLS" will be created if the export
> process succeeds.
> ERROR: Execute: Unable to insert row
> WARNING: File deletion failed for _IMEX_.TEST_PAY.DATA.
> ERROR: Export unsuccessful.  See SAS Log for details.
> NOTE: The SAS System stopped processing this step because of errors.
> NOTE: PROCEDURE EXPORT used (Total process time):
>       real time           15.63 seconds
>       cpu time            11.07 seconds
> /*             ===========================================*/
>
> Regards,
> Amar Mundankar.

7. DelGobbo's XML Tagset: Unable to assign a FILEREF for the

8. how to clear work library

i am using sas for win 8.2. is there some line of code i can insert into 
my program that will clear the contents of the work library without 
having to quit the sas program? this would be the code equivalent to 
going into the explorer window, opening up the work folder and right 
clicking on each temp data set and choosing delete.

thank you
doyle