<?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 Re: establishing additional &amp;quot;work&amp;quot; libraries? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477980#M123193</link>
    <description>&lt;P&gt;I think this might be what I'm after. Thanks for the suggestion! Searching the forum pulls up the following page:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/create-sub-folder-in-work/td-p/214934" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/create-sub-folder-in-work/td-p/214934&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like I can use the above process to establish a uniquely named directory inside WORK, and then point my own libname at it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW - Unfortunately I probably wasn't clear in my first post. I don't want the macro to literally write its datasets to WORK. I do want to specify a library, but I want the pathway for that library to be dynamic and unique, and ideally for the SAS system to perform garbage cleanup just as it does for WORK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jul 2018 18:11:54 GMT</pubDate>
    <dc:creator>desertsp</dc:creator>
    <dc:date>2018-07-13T18:11:54Z</dc:date>
    <item>
      <title>establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477937#M123173</link>
      <description>&lt;P&gt;I have a macro for which I would like to use an alternative "work" library, to avoid any potential for collisions with datasets not associated with the macro. There could even be multiple instances of the macro running simultaneously within the same SAS session, or in separate sessions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently this is the solution I'm considering:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;libname macwork  'c:\temp\randomletters';&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The downside is I need to manage the directory c:\temp\randomletters'. I know this can be done in SAS by creating a random string, then creating the directory, then mounting the library, and (hopefully) deleting the directory afterwards, however this seems like reinventing the wheel. The normal WORK library already handles all of this: &amp;amp;address always has an element of randomness:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let address = %sysfunc(pathname(WORK)); 
%put &amp;amp;address;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Is it possible to establish additional "work" libraries in the same SAS session which would have unique names? &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 16:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477937#M123173</guid>
      <dc:creator>desertsp</dc:creator>
      <dc:date>2018-07-13T16:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477939#M123174</link>
      <description>&lt;P&gt;Not sure about work libraries, but if you assign a library with the name user that becomes the default. You still have the issue of managing the space and ensuring it's purged after.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/103008"&gt;@desertsp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a macro for which I would like to use an alternative "work" library, to avoid any potential for collisions with datasets not associated with the macro. There could even be multiple instances of the macro running simultaneously (i.e. in multiple SAS sessions) on the same computer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently this is the solution I'm considering:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;libname macwork  'c:\temp\randomletters';&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The downside is I need to manage the directory c:\temp\randomletters'. I know this can be done in SAS by creating a random string, then creating the directory, then mounting the library, and (hopefully) deleting the directory afterwards, however this seems like reinventing the wheel. The normal WORK library already handles all of this: &amp;amp;address always has an element of randomness:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let address = %sysfunc(pathname(WORK)); 
%put &amp;amp;address;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Is it possible to establish additional "work" libraries in the same SAS session which would have unique names? &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 16:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477939#M123174</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-13T16:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477955#M123183</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/103008"&gt;@desertsp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a macro for which I would like to use an alternative "work" library, to avoid any potential &lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;for collisions with datasets not associated with the macro&lt;/FONT&gt;&lt;/STRONG&gt;. There could even be multiple instances of the macro running simultaneously within the same SAS session, or in separate sessions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A serious concern but the best solution is to control which library anything gets written to. The only data sets I have in my WORK library are ones that for most purposes exist for one or two steps and I don't care about them. If you have multiple instances then the only way you&amp;nbsp; are going to control that is to specify a library. A routine and repetitive task is what computers are designed for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the system option DLCREATEDIR then you don't need to explicitly create the directory in your libname statement as that option allows a libname statement to create the needed directory.&lt;/P&gt;
&lt;P&gt;If you name all of these "temporary" libraries with a consistent name it would not be hard to write a clean up program to clean them up and %include the code to call that cleanup as needed, or use an autocall macro.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 17:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477955#M123183</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-13T17:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477958#M123184</link>
      <description>&lt;P&gt;By using subfolders of the WORK directory you can avoid conflicts between separate SAS sessions and let SAS do the clean-up afterwards automatically.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 17:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477958#M123184</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-07-13T17:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477961#M123185</link>
      <description>&lt;P&gt;Only issue is how to generate unique names that don't collide as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;By using subfolders of the WORK directory you can avoid conflicts between separate SAS sessions and let SAS do the clean-up afterwards automatically.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 17:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477961#M123185</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-13T17:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477972#M123190</link>
      <description>&lt;P&gt;This should be manageable by the random letter approach&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/103008"&gt;@desertsp&lt;/a&gt;&amp;nbsp;already mentioned (perhaps using the &lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0y09yghr5r11cn1b4ocojwqvrqe.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;UUIDGEN function&lt;/A&gt;). A&amp;nbsp;datetime stamp in the folder name might work as well, unless the time between two DATETIME() calls becomes too short.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 17:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477972#M123190</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-07-13T17:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477975#M123191</link>
      <description>&lt;P&gt;I think this is a portable approach that works in all of the suggestions here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dlcreatedir;

libname work1 "%sysfunc(getoption(WORK))/%sysfunc(uuidgen())" access=temp;
libname work2 "%sysfunc(getoption(WORK))/%sysfunc(uuidgen())" access=temp;
libname work3 "%sysfunc(getoption(WORK))/%sysfunc(uuidgen())" access=temp;
libname work4 "%sysfunc(getoption(WORK))/%sysfunc(uuidgen())" access=temp;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 18:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477975#M123191</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-07-13T18:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477980#M123193</link>
      <description>&lt;P&gt;I think this might be what I'm after. Thanks for the suggestion! Searching the forum pulls up the following page:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/create-sub-folder-in-work/td-p/214934" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/create-sub-folder-in-work/td-p/214934&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like I can use the above process to establish a uniquely named directory inside WORK, and then point my own libname at it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW - Unfortunately I probably wasn't clear in my first post. I don't want the macro to literally write its datasets to WORK. I do want to specify a library, but I want the pathway for that library to be dynamic and unique, and ideally for the SAS system to perform garbage cleanup just as it does for WORK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 18:11:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477980#M123193</guid>
      <dc:creator>desertsp</dc:creator>
      <dc:date>2018-07-13T18:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477992#M123199</link>
      <description>&lt;P&gt;Thanks Chris. That is exactly what I needed (so were the other posts...but you pulled it all together for me).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 18:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477992#M123199</guid>
      <dc:creator>desertsp</dc:creator>
      <dc:date>2018-07-13T18:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/478016#M123209</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I think this is a portable approach that works in all of the suggestions here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dlcreatedir;

libname work1 "%sysfunc(getoption(WORK))/%sysfunc(uuidgen())" access=temp;
libname work2 "%sysfunc(getoption(WORK))/%sysfunc(uuidgen())" access=temp;
libname work3 "%sysfunc(getoption(WORK))/%sysfunc(uuidgen())" access=temp;
libname work4 "%sysfunc(getoption(WORK))/%sysfunc(uuidgen())" access=temp;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Chris&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then as I understand things, you would still have to clean up this folder, otherwise the data sets in work1 (and work2 ...) remain on the hard disk.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 19:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/478016#M123209</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-13T19:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/478024#M123211</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then as I understand things, you would still have to clean up this folder, otherwise the data sets in work1 (and work2 ...) remain on the hard disk.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not on my system (unless I set the NOWORKTERM option), SAS 9.4 under Windows 7.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 20:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/478024#M123211</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-07-13T20:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/478031#M123212</link>
      <description>&lt;P&gt;On my system (Windows 10), the files remain on the hard disk, taking up space, until I close SAS. I guess that's why I was considering deleting them when no longer needed, in case I have a very long program with large datasets, it seems like deleting them when no longer needed is a prudent idea.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 20:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/478031#M123212</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-13T20:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: establishing additional "work" libraries?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/478037#M123214</link>
      <description>&lt;P&gt;Ah okay, you meant those work files pertaining to a particular macro call should be deleted when the program has finished using them. Good point. Sorry, I&amp;nbsp;was thinking only of the clean-up at the end of the SAS session.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 21:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/478037#M123214</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-07-13T21:03:07Z</dc:date>
    </item>
  </channel>
</rss>

