<?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: MACRO parameter  - Reading File name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MACRO-parameter-Reading-File-name/m-p/306991#M65710</link>
    <description>Small changes but definitely got to learn new things about MACRO's.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;BR /&gt;Ana</description>
    <pubDate>Mon, 24 Oct 2016 23:43:48 GMT</pubDate>
    <dc:creator>SASAna</dc:creator>
    <dc:date>2016-10-24T23:43:48Z</dc:date>
    <item>
      <title>MACRO parameter  - Reading File name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-parameter-Reading-File-name/m-p/306984#M65707</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help with reading a FILENAME&amp;nbsp;from macro parameter &amp;amp; import it. &amp;nbsp;I am able to read the file if i hardcode it in the program, but macro parameter is not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO TESTING(&lt;STRONG&gt;FILENAME&lt;/STRONG&gt;=,KEY=,TABLE=);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import datafile= '/testpath/&lt;STRONG&gt;&amp;amp;FILENAME&lt;/STRONG&gt;' &amp;nbsp; &amp;nbsp;/* this is currently resoving as '/testpath/&amp;amp;FILENAME.xlsx not found */&lt;/P&gt;&lt;P&gt;out=TEST_DATASET&lt;BR /&gt;DBMS=XLSX&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DataTest_DS;&lt;/P&gt;&lt;P&gt;set&amp;nbsp;&lt;SPAN&gt;TEST&lt;/SPAN&gt;&lt;SPAN&gt;_DATASET;&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;%MEND;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%&lt;SPAN&gt;TESTING (FILENAME ='TEST_FILE',KEY&lt;SPAN&gt;='GREEN',TABLE=GREEN_TABLE);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 23:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-parameter-Reading-File-name/m-p/306984#M65707</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2016-10-24T23:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO parameter  - Reading File name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-parameter-Reading-File-name/m-p/306990#M65709</link>
      <description>&lt;P&gt;I see two issues:&lt;/P&gt;
&lt;P&gt;1. In the macro defintion, you should use double quotes around the file path, i.e. "/testpath/&amp;amp;FILENAME".&amp;nbsp; Macro variables do not resolved inside of single quotes. So currently it is looking for an Excel file that named &amp;amp;FILENAME.xlsx.&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; When you call the macro, &amp;nbsp;&amp;nbsp;you should not put quotes around the values you pass to the FileName parameter.&amp;nbsp; Try:&lt;/P&gt;
&lt;P&gt;%TESTING (FILENAME =TEST_FILE,KEY='GREEN',TABLE=GREEN_TABLE);&lt;/P&gt;
&lt;P&gt;If you put the quote marks, they become part of the value.&amp;nbsp; And your PROC EXPORT statement would have extra quote marks, so would look like:&amp;nbsp; proc import datafile= "/testpath/'TEST_FILE'"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to check these things is to turn on options MPRINT, which will show in the log the SAS code that is generated by the macro. It's very helpful for debuggin macros.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 23:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-parameter-Reading-File-name/m-p/306990#M65709</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-10-24T23:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO parameter  - Reading File name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-parameter-Reading-File-name/m-p/306991#M65710</link>
      <description>Small changes but definitely got to learn new things about MACRO's.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;BR /&gt;Ana</description>
      <pubDate>Mon, 24 Oct 2016 23:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-parameter-Reading-File-name/m-p/306991#M65710</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2016-10-24T23:43:48Z</dc:date>
    </item>
  </channel>
</rss>

