<?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: Set libname in a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409082#M99921</link>
    <description>Thanks a lot. It's working now</description>
    <pubDate>Tue, 31 Oct 2017 12:28:23 GMT</pubDate>
    <dc:creator>chris2377</dc:creator>
    <dc:date>2017-10-31T12:28:23Z</dc:date>
    <item>
      <title>Set libname in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409063#M99917</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a given catalogue, I have a number of xlsm files that I want to import to SAS using libname excel. The files are named sales_2013.xlsm, sales_2014.xlsm etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried the following loop&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint mlogic symbolgen;
%macro set_libname;
%do i=2013 %to 2016;
	options validvarname=any validmemname=extend;
	libname scen&amp;amp;i excel "C:\Data\sales_&amp;amp;i.xlsm" access=read;
%end;
%mend;
%set_libname; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, the code produces&amp;nbsp;the following error: "ERROR: ERROR: File extension specified is invalid". In the log I can see that SAS resolves the path to e.g.&amp;nbsp;"C:\Data\sales_2013". So, it ignores the ".xlsm" extension, which - I guess - causes the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I fix it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 11:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409063#M99917</guid>
      <dc:creator>chris2377</dc:creator>
      <dc:date>2017-10-31T11:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Set libname in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409076#M99920</link>
      <description>&lt;P&gt;Note that a dot is used to terminate macro variable names, which is especially needed when macro variables are used within a string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname scen&amp;amp;i excel "C:\Data\sales_&amp;amp;i..xlsm" access=read;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first dot terminates the variable call &amp;amp;i, the second one will appear in the resulting filename.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 12:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409076#M99920</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-31T12:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Set libname in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409082#M99921</link>
      <description>Thanks a lot. It's working now</description>
      <pubDate>Tue, 31 Oct 2017 12:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409082#M99921</guid>
      <dc:creator>chris2377</dc:creator>
      <dc:date>2017-10-31T12:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Set libname in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409083#M99922</link>
      <description>&lt;P&gt;Perhaps another Maxim is needed,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Always use the dot after macro variables!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 12:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409083#M99922</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-31T12:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Set libname in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409087#M99923</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Perhaps another Maxim is needed,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Always use the dot after macro variables!&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Done. Maxim 48.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 12:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-libname-in-a-macro/m-p/409087#M99923</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-31T12:40:51Z</dc:date>
    </item>
  </channel>
</rss>

