<?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 Variable and Quotations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528863#M144396</link>
    <description>&lt;P&gt;And also see Maxim 44.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jan 2019 18:57:01 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-01-21T18:57:01Z</dc:date>
    <item>
      <title>Macro Variable and Quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528840#M144379</link>
      <description>&lt;P&gt;I have the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dir_of_tracks=\\ncrfp4\AtlanticAnalysis\NAT Track Analysis\Track Data\Nov-2018;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;filename DIRLIST pipe 'dir "\\ncrfp4\AtlanticAnalysis\NAT Track Analysis\Track Data\Nov-2018\NatTrackDetails_2*.csv" /b ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;call symputx('read'||put(count,4.-l),cats('\\ncrfp4\AtlanticAnalysis\NAT Track Analysis\Track Data\Nov-2018\',file_name));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to replace the paths in the filename DIRLIST pipe commands with the macro variable dir _of_tracks that you see declared. Of course the filename DIRLIST pipe&amp;nbsp;line has quotes, as does the call symputx below it/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="3"&gt;How can I add in the &amp;amp;dir_of_tracks within these double and single quotes.....probably easy, but these details I always forget. Quotes always mess me up.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528840#M144379</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2019-01-21T18:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable and Quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528852#M144387</link>
      <description>&lt;P&gt;To get macro variables to resolve you need to use the doublequotes on the outside, and single quotes (if needed) on the inside.&amp;nbsp; In that case, this means:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let dir_of_tracks=\\ncrfp4\AtlanticAnalysis\NAT Track Analysis\Track Data\Nov-2018;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you have:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;filename DIRLIST pipe 'dir "\\ncrfp4\AtlanticAnalysis\NAT Track Analysis\Track Data\Nov-2018\NatTrackDetails_2*.csv" /b ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you should have instead:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;filename DIRLIST pipe "dir '&amp;amp;dir_of_tracks.\NatTrackDetails_2*.csv' /b ";&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528852#M144387</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-21T18:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable and Quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528855#M144390</link>
      <description>&lt;P&gt;In the filename pipe, replace double with single quotes, and vice versa.&lt;/P&gt;
&lt;P&gt;Use double quotes when macro triggers should be resolved.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528855#M144390</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-21T18:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable and Quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528860#M144393</link>
      <description>&lt;P&gt;You need to use double quote characters as the outside quotes. The macro processor ignores strings inside of single quotes.&amp;nbsp;Plus the DOS command line needs quotes around paths that can contain spaces or else the spaces will be interpreted as delimiting new arguments for the commands.&amp;nbsp; When you want to have a quote as parted of a quoted string you need to double up those embedded quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename DIRLIST pipe "dir /b ""&amp;amp;dir_of_tracks\NatTrackDetails_2*.csv""";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I find that the QUOTE() function is useful for this.&lt;/P&gt;
&lt;P&gt;For example you could generate the command as a dataset variable which you can pass to the INFILE statement using the FILEVAR= option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data filelist;
  length cmd $200;
  cmd=catx(' ','dir /b',quote(catx('\',"&amp;amp;dir_of_tracks",'NatTrackDetails_2*.csv')));
  infile dummy pipe filevar=cmd  truncover;
  input filename $256. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can use the macro function %SYSFUNC() to let you use the QUOTE() function to generate code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename DIRLIST pipe %sysfunc(quote(dir /b "&amp;amp;dir_of_tracks\NatTrackDetails_2*.csv"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 19:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528860#M144393</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-21T19:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable and Quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528863#M144396</link>
      <description>&lt;P&gt;And also see Maxim 44.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-and-Quotations/m-p/528863#M144396</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-21T18:57:01Z</dc:date>
    </item>
  </channel>
</rss>

