<?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: How to create various libname in a do loop in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510860#M32443</link>
    <description>&lt;P&gt;Hello Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have test the following code and it seems to work.&lt;/P&gt;&lt;P&gt;Please note that if the code below is executed without the instruction LIBNAME _ALL_ LIST; the libnames that you have just create&amp;nbsp;won't appear in the log file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;DeclareLib&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName1=data_2_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName2=data_5_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName3=data_10_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName4=data_20_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mylib=\\...\Documents\Test\Parallel Processing\XML\&amp;amp;&amp;amp;FileName&amp;amp;i...xml;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;mylib;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(libname(lib&amp;amp;i,&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mylib.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,xml,xmltype=oracle))) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(sysmsg());&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LIBNAME _ALL_ LIST;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DeclareLib;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;DeclareLib&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Nov 2018 19:09:49 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2018-11-06T19:09:49Z</dc:date>
    <item>
      <title>How to create various libname in a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510735#M32430</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create libname statement in a do loop before going into a parallel process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to obtain libname as follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname libr1 "\\...Documents\Test\Parallel Processing\XML\test1.xml';&lt;/P&gt;&lt;P&gt;libname libr2 "\\...Documents\Test\Parallel Processing\XML\test2.xml';&lt;/P&gt;&lt;P&gt;libname libr3 "\\...Documents\Test\Parallel Processing\XML\test3.xml';&lt;/P&gt;&lt;P&gt;libname libr4 "\\...Documents\Test\Parallel Processing\XML\test4.xml';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 13:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510735#M32430</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2018-11-06T13:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create various libname in a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510742#M32432</link>
      <description>&lt;P&gt;To do this with a DO loop (rather than a macro %DO loop):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;do n=1 to 4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; call execute ('libname libr' || put(n, 1.) || ' "&lt;SPAN&gt;\\...Documents\Test\Parallel Processing\XML\test' || put(n, 1.) || '.xml"; ');&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It becomes mildly more complex if you need to define more than 9 LIBNAME statements, because of the 1. format in the PUT function.&amp;nbsp; But that can be expanded to 2. and the LEFT function applied to the result.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 13:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510742#M32432</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-11-06T13:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create various libname in a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510781#M32437</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution you have proposed works well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I need to use the following filename for my preliminary tests:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName1=data_2_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName2=data_5_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName3=data_10_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName4=data_20_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;So I need to generate the following instructions:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;libname lib1 xmlv2 "\\...\xml\&lt;FONT face="Courier New"&gt;data_2_500000&lt;/FONT&gt;.xml";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;libname lib2 xmlv2 "\\...\xml\data_5_500000.xml";&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;libname lib3 xmlv2 "\\...\xml\data_10_500000.xml";&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;libname lib4 xmlv2 "\\...\xml\data_20_500000.xml";&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;How can we do that?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 15:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510781#M32437</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2018-11-06T15:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create various libname in a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510788#M32439</link>
      <description>There's also a LIBNAME function. &lt;BR /&gt;&lt;BR /&gt;Untested and likely won't work but gives you the idea.&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;do i=1 to 4;&lt;BR /&gt;ref=lib||put(i, 8.-l);&lt;BR /&gt;str = "path to library"||i||".xml";&lt;BR /&gt;rc=libname(ref, str);&lt;BR /&gt;end;&lt;BR /&gt;run;</description>
      <pubDate>Tue, 06 Nov 2018 15:50:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510788#M32439</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-06T15:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to create various libname in a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510860#M32443</link>
      <description>&lt;P&gt;Hello Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have test the following code and it seems to work.&lt;/P&gt;&lt;P&gt;Please note that if the code below is executed without the instruction LIBNAME _ALL_ LIST; the libnames that you have just create&amp;nbsp;won't appear in the log file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;DeclareLib&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName1=data_2_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName2=data_5_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName3=data_10_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FileName4=data_20_500000;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mylib=\\...\Documents\Test\Parallel Processing\XML\&amp;amp;&amp;amp;FileName&amp;amp;i...xml;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;mylib;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(libname(lib&amp;amp;i,&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;mylib.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,xml,xmltype=oracle))) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(sysmsg());&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LIBNAME _ALL_ LIST;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DeclareLib;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;DeclareLib&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 19:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510860#M32443</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2018-11-06T19:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to create various libname in a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510861#M32444</link>
      <description>If you only have 4 though, plain vanilla libnames are more efficient.</description>
      <pubDate>Tue, 06 Nov 2018 19:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510861#M32444</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-06T19:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to create various libname in a do loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510867#M32445</link>
      <description>&lt;P&gt;I agree with you but believe me I have much more than 4 libnames to declare.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 19:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-various-libname-in-a-do-loop/m-p/510867#M32445</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2018-11-06T19:27:13Z</dc:date>
    </item>
  </channel>
</rss>

