<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error with Macro library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37206#M7353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; without the data step code, you can assign a "random" libref like&lt;/P&gt;&lt;P&gt;﻿libname A%scan( %sysfunc( ranuni(0), 9.7 ),2,.) 'physical path to library' ;&lt;/P&gt;&lt;P&gt;it creates a libref that is unlikely to repeat having a random 7 digit number following that A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just tested it and it even works within a %sysfunc( repeat( ,4 )) where it happily assigned 5 unique libnames (all with the same path)&lt;/P&gt;&lt;P&gt;%sysfunc( repeat( %nrstr( &lt;/P&gt;&lt;P&gt;﻿libname A %%scan( %%sysfunc( ranuni(0), 9.7 ), 2, . ) 'my path' ;&lt;/P&gt;&lt;P&gt; ), 4 ) ) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason the macros libname won't release is its use in option ﻿sasmstore=macros ;&lt;/P&gt;&lt;P&gt;I'm not sure you can release the sasmstore assignment﻿. (nor sure I would want to release it)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use Scott's approach - not performing the assignment of the macros libname after the first run. Place "one-time-only" code in the autoexec.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Aug 2011 12:12:25 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2011-08-02T12:12:25Z</dc:date>
    <item>
      <title>Error with Macro library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37201#M7348</link>
      <description>I am running a macro with following syntax for options, &lt;BR /&gt;
&lt;BR /&gt;
Dm 'log;clear;output;clear;';&lt;BR /&gt;
LIBNAME XYZZZ 'U:\0xxx Protocol\xxxx_Completedata_XYZZ';&lt;BR /&gt;
LIBNAME LIBRARY 'C:\Users\rmalapati\Documents\My SAS Files\Sangamo_SB_509_0801\0801 Protocol\formats';&lt;BR /&gt;
options linesize=200 pagesize=100;&lt;BR /&gt;
libname macros 'U:\Macros';&lt;BR /&gt;
options mprint mlogic mstored sasmstore=macros;&lt;BR /&gt;
options linesize=256 pagesize=100;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
&lt;BR /&gt;
The following error gets displayed after running the sas for second time, but when running on a new sas sesison with the same syntax the error cant be seen.&lt;BR /&gt;
&lt;BR /&gt;
I know why the error is being displayed but am not able to get the right solution&lt;BR /&gt;
&lt;BR /&gt;
"ERROR: Unable to clear or re-assign the library MACROS because it is still in use.&lt;BR /&gt;
ERROR: Error in the LIBNAME statement."&lt;BR /&gt;
&lt;BR /&gt;
How to get around this?</description>
      <pubDate>Fri, 19 Nov 2010 18:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37201#M7348</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-19T18:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Macro library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37202#M7349</link>
      <description>Hello SAS_PHARM,&lt;BR /&gt;
&lt;BR /&gt;
Simply move the line &lt;BR /&gt;
[pre]&lt;BR /&gt;
libname macros 'U:\Macros';&lt;BR /&gt;
[/pre]&lt;BR /&gt;
to the top and second (third, etc. ) time &lt;BR /&gt;
submit a block of code not including this line.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Fri, 19 Nov 2010 19:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37202#M7349</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-19T19:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Macro library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37203#M7350</link>
      <description>Or . You need one more statement to release your libname.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
libname macros clear;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 22 Nov 2010 03:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37203#M7350</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-11-22T03:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Macro library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37204#M7351</link>
      <description>This won't help you now, but when 9.3 comes out, it will have a &lt;BR /&gt;
%SYSMSTORECLEAR statement that will close the current library and clear the libref.</description>
      <pubDate>Mon, 13 Dec 2010 14:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37204#M7351</guid>
      <dc:creator>PatrickG</dc:creator>
      <dc:date>2010-12-13T14:19:16Z</dc:date>
    </item>
    <item>
      <title>Error with Macro library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37205#M7352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I haven't found an elegant solution, but I'm using this code in Enterprise Guide:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*-- start code --;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length WORD $8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j = 1 to 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WORD = byte(int(65 + ranuni(0)*26)) || WORD;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("mylibrary", WORD);&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname &amp;amp;mylibrary 'physical_path_to_library';&lt;/P&gt;&lt;P&gt;*-- end code --;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This assign every time a different random LIBREF to you library.&lt;/P&gt;&lt;P&gt;It works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Paolo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2011 11:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37205#M7352</guid>
      <dc:creator>pcavicch</dc:creator>
      <dc:date>2011-08-02T11:38:14Z</dc:date>
    </item>
    <item>
      <title>Error with Macro library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37206#M7353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; without the data step code, you can assign a "random" libref like&lt;/P&gt;&lt;P&gt;﻿libname A%scan( %sysfunc( ranuni(0), 9.7 ),2,.) 'physical path to library' ;&lt;/P&gt;&lt;P&gt;it creates a libref that is unlikely to repeat having a random 7 digit number following that A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just tested it and it even works within a %sysfunc( repeat( ,4 )) where it happily assigned 5 unique libnames (all with the same path)&lt;/P&gt;&lt;P&gt;%sysfunc( repeat( %nrstr( &lt;/P&gt;&lt;P&gt;﻿libname A %%scan( %%sysfunc( ranuni(0), 9.7 ), 2, . ) 'my path' ;&lt;/P&gt;&lt;P&gt; ), 4 ) ) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason the macros libname won't release is its use in option ﻿sasmstore=macros ;&lt;/P&gt;&lt;P&gt;I'm not sure you can release the sasmstore assignment﻿. (nor sure I would want to release it)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use Scott's approach - not performing the assignment of the macros libname after the first run. Place "one-time-only" code in the autoexec.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2011 12:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-with-Macro-library/m-p/37206#M7353</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-08-02T12:12:25Z</dc:date>
    </item>
  </channel>
</rss>

