<?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: file name contains &amp; in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/file-name-contains/m-p/10756#M1088</link>
    <description>Hi:&lt;BR /&gt;
  If you read up on SAS Macro processing, you will find out that there are special "Macro Quoting Functions" that protect or hide the normal meaning of special characters, such as % and &amp;amp;.  (And do quoting, unquoting, protection at compile time, protection at execution time, etc, etc -- it's a long list.)&lt;BR /&gt;
 &lt;BR /&gt;
  Your code -- a single PROC IMPORT step -- without any other macro variable references -- only needs a simple level of protection. The %NRSTR function will do what you want to do -- for the code that you've shown. The correct way to use the %NRSTR function is:&lt;BR /&gt;
[pre]&lt;BR /&gt;
datafile ="C:\temp\%nrstr(PT&amp;amp;TT.xls)" &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
The documentation is here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#z3514str.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#z3514str.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
In the long run, it might be better to avoid the use of &amp;amp; and % especially in the names of files, because you will continue to have this problem and need to work around it. And eventually, if you -do- need to use &amp;amp; and/or % in their context as macro triggers (such as when you might need to write a macro program), having the &amp;amp; in the file name just complicates things.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Sat, 02 Oct 2010 16:03:01 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-10-02T16:03:01Z</dc:date>
    <item>
      <title>file name contains &amp;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/file-name-contains/m-p/10755#M1087</link>
      <description>Help please.&lt;BR /&gt;
&lt;BR /&gt;
proc import &lt;BR /&gt;
out=mailling_working&lt;BR /&gt;
datafile ="C:\sample\PT&amp;amp;TT.xls";&lt;BR /&gt;
dbms =excel replace;&lt;BR /&gt;
sheet = "All Mailed";&lt;BR /&gt;
mixed =yes;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Since the file PT&amp;amp;TT.xls contains &amp;amp;, SAS would think &amp;amp;TT.xls is macro variable. This problem can be easily solved by changing the file name, but any suggestion to solve this problem without changing the file name? Because I have lots of files contain &amp;amp;.</description>
      <pubDate>Sat, 02 Oct 2010 07:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/file-name-contains/m-p/10755#M1087</guid>
      <dc:creator>piggy</dc:creator>
      <dc:date>2010-10-02T07:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: file name contains &amp;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/file-name-contains/m-p/10756#M1088</link>
      <description>Hi:&lt;BR /&gt;
  If you read up on SAS Macro processing, you will find out that there are special "Macro Quoting Functions" that protect or hide the normal meaning of special characters, such as % and &amp;amp;.  (And do quoting, unquoting, protection at compile time, protection at execution time, etc, etc -- it's a long list.)&lt;BR /&gt;
 &lt;BR /&gt;
  Your code -- a single PROC IMPORT step -- without any other macro variable references -- only needs a simple level of protection. The %NRSTR function will do what you want to do -- for the code that you've shown. The correct way to use the %NRSTR function is:&lt;BR /&gt;
[pre]&lt;BR /&gt;
datafile ="C:\temp\%nrstr(PT&amp;amp;TT.xls)" &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
The documentation is here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#z3514str.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#z3514str.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
In the long run, it might be better to avoid the use of &amp;amp; and % especially in the names of files, because you will continue to have this problem and need to work around it. And eventually, if you -do- need to use &amp;amp; and/or % in their context as macro triggers (such as when you might need to write a macro program), having the &amp;amp; in the file name just complicates things.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Sat, 02 Oct 2010 16:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/file-name-contains/m-p/10756#M1088</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-10-02T16:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: file name contains &amp;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/file-name-contains/m-p/10757#M1089</link>
      <description>Thanks for your help.&lt;BR /&gt;
&lt;BR /&gt;
I am still at beginner level. &lt;BR /&gt;
This forum is such a good place, it helps me a lot.</description>
      <pubDate>Sat, 02 Oct 2010 20:32:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/file-name-contains/m-p/10757#M1089</guid>
      <dc:creator>piggy</dc:creator>
      <dc:date>2010-10-02T20:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: file name contains &amp;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/file-name-contains/m-p/10758#M1090</link>
      <description>A simplier solution IF you do not need to resolve any macro variables elsewhere within the datafile name is to use a single quote ' instead of double quotes ".&lt;BR /&gt;
&lt;BR /&gt;
Unlike many programming languages SAS supports both types of quotes with the difference involving macro variable resolution.</description>
      <pubDate>Tue, 05 Oct 2010 16:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/file-name-contains/m-p/10758#M1090</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2010-10-05T16:24:16Z</dc:date>
    </item>
  </channel>
</rss>

