<?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: Save Libnames, Restore Libnames in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Save-Libnames-Restore-Libnames/m-p/483507#M125373</link>
    <description>&lt;P&gt;I couldn't use an explicit path because there could be multiple people running the same program (thus the date and userid).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;CURRENTPATH and&amp;nbsp;&amp;amp;ymd8 are variables I calculate...just examples of possible directory structures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There can be all sorts of other libnames to exclude.&amp;nbsp;&amp;nbsp;I have a lot more...I basically added anything that gave me an error.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Aug 2018 18:15:21 GMT</pubDate>
    <dc:creator>tomrvincent</dc:creator>
    <dc:date>2018-08-02T18:15:21Z</dc:date>
    <item>
      <title>Save Libnames, Restore Libnames</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Save-Libnames-Restore-Libnames/m-p/483466#M125365</link>
      <description>&lt;P&gt;If you need to save all your libnames and then be able to&amp;nbsp;restore them later, here's how I do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* save libnames&amp;nbsp; somewhere...I use the program's current path with the date and userid subdirectories*/&lt;BR /&gt;proc sql; create table foo as select distinct 'libname ' || libname || ' "' || trim(path) || '";' as libname format $500. from sashelp.vlibnam&lt;BR /&gt;where libname not in ('MAPSGFK','MAPSSAS','SASHELP','WORK');quit;&lt;/P&gt;
&lt;P&gt;data _null_; &lt;BR /&gt; file "&amp;amp;CURRENTPATH.&amp;amp;YMD8/&amp;amp;SYSUSERID/libnames.sas";&lt;BR /&gt; set foo; libname = trim(libname); put libname;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in some other program (or, for parallel projects, I put it in the 'insert custom code before submitted code'):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%include "&amp;amp;CURRENTPATH.&amp;amp;YMD8/&amp;amp;SYSUSERID/libnames.sas";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 16:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Save-Libnames-Restore-Libnames/m-p/483466#M125365</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-08-02T16:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Save Libnames, Restore Libnames</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Save-Libnames-Restore-Libnames/m-p/483502#M125370</link>
      <description>&lt;P&gt;The SQL is not needed and use of the CATX function makes for cleaner string creation.&lt;/P&gt;
&lt;P&gt;Also examination of the SASHELP.VLIBNAM will show that distinct is needed because of additional variables to indicate which row to use.&lt;/P&gt;
&lt;PRE&gt;data _null_; 
 set sashelp.vlibnam;
 /* add any SAS supplied libraries in the list below*/
 where libname not in ('MAPSGFK','MAPSSAS','SASHELP','WORK')
       and sysname='Filename';
 file "&amp;amp;CURRENTPATH.&amp;amp;YMD8/&amp;amp;SYSUSERID/libnames.sas";
 length libstr $ 500;
 libstr = catx(' ', 'libname',libname, quote(strip(path)),';');
 put libstr;
run;&lt;/PRE&gt;
&lt;P&gt;Personally I would also include the SASUSER library in the exclusion list as using that SAS library potentially can get you in trouble with SAS updates and reinstall overwriting or using a different location.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might also consider using an explicit path in the file statement as the &amp;amp;CURRENTPATH and&amp;nbsp;&amp;amp;ymd8 variables may not be defined in all environments (Not in mine for sure).&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 17:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Save-Libnames-Restore-Libnames/m-p/483502#M125370</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-02T17:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Save Libnames, Restore Libnames</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Save-Libnames-Restore-Libnames/m-p/483507#M125373</link>
      <description>&lt;P&gt;I couldn't use an explicit path because there could be multiple people running the same program (thus the date and userid).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;CURRENTPATH and&amp;nbsp;&amp;amp;ymd8 are variables I calculate...just examples of possible directory structures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There can be all sorts of other libnames to exclude.&amp;nbsp;&amp;nbsp;I have a lot more...I basically added anything that gave me an error.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 18:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Save-Libnames-Restore-Libnames/m-p/483507#M125373</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-08-02T18:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Save Libnames, Restore Libnames</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Save-Libnames-Restore-Libnames/m-p/483558#M125405</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/144199"&gt;@tomrvincent&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I couldn't use an explicit path because there could be multiple people running the same program (thus the date and userid).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;CURRENTPATH and&amp;nbsp;&amp;amp;ymd8 are variables I calculate...just examples of possible directory structures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There can be all sorts of other libnames to exclude.&amp;nbsp;&amp;nbsp;I have a lot more...I basically added anything that gave me an error.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Understood.&lt;/P&gt;
&lt;P&gt;When providing an example for others it is helpful to indicate that about your macro variables &amp;amp;CURRENTPATH and&amp;nbsp;&amp;amp;ymd8 were used and set by you elsewhere in code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since there are varying SAS automatic variables from different installations and modules&amp;nbsp;I was not sure if those were system or user variables.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 19:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Save-Libnames-Restore-Libnames/m-p/483558#M125405</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-02T19:47:11Z</dc:date>
    </item>
  </channel>
</rss>

