<?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 use sas macro to replace a path in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350081#M81325</link>
    <description>&lt;P&gt;Macro&amp;nbsp;triggers are not resolved inside of single quotes. Use double quotes instead if you want SAS to recognize the reference to the macro &lt;STRONG&gt;variable&lt;/STRONG&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let datapath= d:\ce\fi\gh ;

filename DIRLIST pipe "dir ""&amp;amp;datapath\*.txt"" /b";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use the macro function %SYSFUNC() to call the QUOTE() function to make it easier. That way you do not need to double up the embedded double quote characters in the command string since the QUOTE() function will take care of that for you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename DIRLIST pipe %sysfunc(quote(dir "&amp;amp;datapath\*.txt" /b));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 14 Apr 2017 15:41:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-04-14T15:41:51Z</dc:date>
    <item>
      <title>how to use sas macro to replace a path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350077#M81324</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find&amp;nbsp; “pipe” is quite helpful. I need to replace the old path with a&amp;nbsp;different path so I am thinking to use a macro to do the work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The old one:&lt;/P&gt;
&lt;P&gt;filename DIRLIST pipe 'dir "C:\ab\c\*.txt" /b ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; dirlist ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; infile dirlist lrecl=&lt;STRONG&gt;200&lt;/STRONG&gt; truncover;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input file_name $100.;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am thinking to define a sas macro like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let datapath= d:\ce\fi\gh&lt;/P&gt;
&lt;P&gt;And then put &amp;amp;datapath to replace the old path. It seems it does&amp;nbsp;not work. Any advice how to define a sas macro to replace old path// no lib is needed&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 15:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350077#M81324</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2017-04-14T15:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to use sas macro to replace a path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350081#M81325</link>
      <description>&lt;P&gt;Macro&amp;nbsp;triggers are not resolved inside of single quotes. Use double quotes instead if you want SAS to recognize the reference to the macro &lt;STRONG&gt;variable&lt;/STRONG&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let datapath= d:\ce\fi\gh ;

filename DIRLIST pipe "dir ""&amp;amp;datapath\*.txt"" /b";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use the macro function %SYSFUNC() to call the QUOTE() function to make it easier. That way you do not need to double up the embedded double quote characters in the command string since the QUOTE() function will take care of that for you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename DIRLIST pipe %sysfunc(quote(dir "&amp;amp;datapath\*.txt" /b));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Apr 2017 15:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350081#M81325</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-14T15:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to use sas macro to replace a path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350083#M81326</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/SAS-Macro-using-doubles-quotes-filename-pipe/td-p/146921" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/SAS-Macro-using-doubles-quotes-filename-pipe/td-p/146921&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 15:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350083#M81326</guid>
      <dc:creator>nehalsanghvi</dc:creator>
      <dc:date>2017-04-14T15:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to use sas macro to replace a path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350084#M81327</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40773"&gt;@Bal23&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find&amp;nbsp; “pipe” is quite helpful. I need to replace the old path with a&amp;nbsp;different path so I am thinking to use a macro to do the work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The old one:&lt;/P&gt;
&lt;P&gt;filename DIRLIST pipe 'dir "C:\ab\c\*.txt" /b ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; dirlist ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; infile dirlist lrecl=&lt;STRONG&gt;200&lt;/STRONG&gt; truncover;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input file_name $100.;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am thinking to define a sas macro like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let datapath= d:\ce\fi\gh&lt;/P&gt;
&lt;P&gt;And then put &amp;amp;datapath to replace the old path. It seems it does&amp;nbsp;not work. Any advice how to define a sas macro to replace old path// no lib is needed&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Inside the single quotes, macro variables are not resolved, so &amp;amp;datapath will fail inside single quotes. Instead, try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Sasfont" size="1"&gt;&lt;FONT size="3"&gt;&lt;CODE class=" language-sas"&gt;filename DIRLIST pipe "dir ""&amp;amp;datapath\*.txt"" /b ";
&lt;/CODE&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Apr 2017 15:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350084#M81327</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-04-14T15:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to use sas macro to replace a path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350091#M81329</link>
      <description>&lt;P&gt;Thank you both of you. Yes, it works.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 16:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-sas-macro-to-replace-a-path/m-p/350091#M81329</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2017-04-14T16:19:15Z</dc:date>
    </item>
  </channel>
</rss>

