<?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 Must I macro quote, or not quote, if quote then what quoting method is best? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/631950#M187289</link>
    <description>&lt;P&gt;Must I macro quote to quote a quote, or not quote, if quote then what quoting method is best, and why? What's the compile time effect vs. execution time effect? what is the delta character wrapper that's used to quote a quote and how stuff works? Then unquote for the SAS complier to execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a supposedly simple issue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename filelist pipe 'dir "\\corp\sites\RIB1001\RMT4PMC\datafiles\MONTH END REPORTS\Monthly Files\2020\202002MonthEnd" /b' ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Would like to parameterize Year/Yearmonthend values using&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Month end information-values*/
%let Year_month=%sysfunc(intnx(month,%sysfunc(today()),-1),yymmn6.);
%put &amp;amp;=Year_month;
%let year=%substr(&amp;amp;Year_month,1,4);
%put &amp;amp;=year;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Quote with BQUOTE works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename filelist pipe %unquote(%bquote('dir "\\corp\sites\RIB1001\RMT4PMC\datafiles\MONTH END REPORTS\Monthly Files\&amp;amp;year\&amp;amp;year_month.MonthEnd" /b')) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and as does with %STR&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename filelist pipe %unquote(%str(%'dir "\\corp\sites\RIB1001\RMT4PMC\datafiles\MONTH END REPORTS\Monthly Files\&amp;amp;year\&amp;amp;year_month.MonthEnd" /b%')) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My attempt to thoroughly understand:&lt;/P&gt;
&lt;P&gt;1. Read the documentation - my dumb brain is still not satisfied&lt;/P&gt;
&lt;P&gt;2. Gonna venture on a book by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;/author Michelle B&amp;nbsp; on Safarionline(I have paid subscription), and see if that's covered&lt;/P&gt;
&lt;P&gt;3. Ask here&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like the finer details please. Please allow me to take time to acknowledge the responses I get once my damn brain processes it. Thank you in advance and my warm regards&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;</description>
    <pubDate>Fri, 13 Mar 2020 16:16:42 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-03-13T16:16:42Z</dc:date>
    <item>
      <title>Must I macro quote, or not quote, if quote then what quoting method is best?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/631950#M187289</link>
      <description>&lt;P&gt;Must I macro quote to quote a quote, or not quote, if quote then what quoting method is best, and why? What's the compile time effect vs. execution time effect? what is the delta character wrapper that's used to quote a quote and how stuff works? Then unquote for the SAS complier to execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a supposedly simple issue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename filelist pipe 'dir "\\corp\sites\RIB1001\RMT4PMC\datafiles\MONTH END REPORTS\Monthly Files\2020\202002MonthEnd" /b' ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Would like to parameterize Year/Yearmonthend values using&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Month end information-values*/
%let Year_month=%sysfunc(intnx(month,%sysfunc(today()),-1),yymmn6.);
%put &amp;amp;=Year_month;
%let year=%substr(&amp;amp;Year_month,1,4);
%put &amp;amp;=year;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Quote with BQUOTE works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename filelist pipe %unquote(%bquote('dir "\\corp\sites\RIB1001\RMT4PMC\datafiles\MONTH END REPORTS\Monthly Files\&amp;amp;year\&amp;amp;year_month.MonthEnd" /b')) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and as does with %STR&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename filelist pipe %unquote(%str(%'dir "\\corp\sites\RIB1001\RMT4PMC\datafiles\MONTH END REPORTS\Monthly Files\&amp;amp;year\&amp;amp;year_month.MonthEnd" /b%')) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My attempt to thoroughly understand:&lt;/P&gt;
&lt;P&gt;1. Read the documentation - my dumb brain is still not satisfied&lt;/P&gt;
&lt;P&gt;2. Gonna venture on a book by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;/author Michelle B&amp;nbsp; on Safarionline(I have paid subscription), and see if that's covered&lt;/P&gt;
&lt;P&gt;3. Ask here&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like the finer details please. Please allow me to take time to acknowledge the responses I get once my damn brain processes it. Thank you in advance and my warm regards&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;</description>
      <pubDate>Fri, 13 Mar 2020 16:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/631950#M187289</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-13T16:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Must I macro quote, or not quote, if quote then what quoting method is best?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/632023#M187335</link>
      <description>&lt;P&gt;Adding to your reading list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/wp-content/uploads/2016/02/bt185.pdf" target="_blank"&gt;https://stats.idre.ucla.edu/wp-content/uploads/2016/02/bt185.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anything you find written by Susan O'Connor is bound to be relevant.&amp;nbsp; She was a prime author of macro language.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 18:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/632023#M187335</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-03-13T18:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Must I macro quote, or not quote, if quote then what quoting method is best?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/632103#M187366</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&amp;nbsp; advice to use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename filelist pipe %sysfunc(quote(dir "\\corp\sites\RIB1001\RMT4PMC\datafiles\MONTH END REPORTS\Monthly Files\&amp;amp;year\&amp;amp;year_month.MonthEnd" /b)) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or single quote&lt;/P&gt;
&lt;PRE&gt; 69         %let year=2010;
 70         %let year_month=201003;
 71         
 72         %let x=%sysfunc(quote(dir '\MONTH END REPORTS\Monthly Files\&amp;amp;year\&amp;amp;year_month.MonthEnd' /b)) ;
 73         
 74         %put &amp;amp;x ;
 "dir '\MONTH END REPORTS\Monthly Files\2010\201003MonthEnd' /b"
 75         &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 11:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/632103#M187366</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-03-14T11:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Must I macro quote, or not quote, if quote then what quoting method is best?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/632169#M187400</link>
      <description>&lt;P&gt;Your example seems simpler than the theoretical issues you started the thread with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want macro triggers evaluated inside of your quoted string you need to use double quotes on the OUTSIDE.&amp;nbsp; &amp;nbsp;When you want to use the character used as the outside quote inside the quoted string just double it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let topnode=\\corp\sites\RIB1001\RMT4PMC\datafiles\MONTH END REPORTS\Monthly Files;
filename filelist pipe "dir ""&amp;amp;topnode\&amp;amp;year\&amp;amp;year_month.MonthEnd"" /b";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You CAN use the %BQUOTE() function.&amp;nbsp; But that will result in a value that is macro quoted, which might solve some problems or introduce new ones depending on how you want to use the value that %BQUOTE() generates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also avoid a lot of these macro quoting issues by just using SAS code instead of macro code.&amp;nbsp; For example you could use the FILENAME() function in a data step instead of the FILENAME statement to define your fileref FILELIST.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 17:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/632169#M187400</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-14T17:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Must I macro quote, or not quote, if quote then what quoting method is best?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/632194#M187410</link>
      <description>&lt;P&gt;Also simply:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename F pipe " dir ""&amp;amp;path"" /b ";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 21:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/632194#M187410</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-03-14T21:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Must I macro quote, or not quote, if quote then what quoting method is best?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/637921#M189674</link>
      <description>&lt;P&gt;Thank you all for chiming in. I am afraid I really didn't get enough time to log on to Safarionline and read as my team and I got swamped with ad-hoc tasks that rose from nowhere. I really intended to keep the thread open and clear some of the conceptual doubts on the macro quote and unquote. Nonetheless, I acknowledge it's unethical to not close thread for much too long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; Filename function is indeed slick and does the job for the example though I would like you to know I would take the liberty in coming back to the thread to get my understanding on macro quoting squeaky clean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp; I couldn't find a book authored by the macro champ person you mentioned on O'reily but I have yours. Is it only UCLA papers?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 18:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/637921#M189674</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-04-06T18:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Must I macro quote, or not quote, if quote then what quoting method is best?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/637957#M189690</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have a list of papers that Susan has written, or know where to find them all.&amp;nbsp; To the best of my knowledge she has not written a book.&amp;nbsp; But she has presented at a few SAS conferences and any paper she has presented is worth reading.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy hunting!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 22:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Must-I-macro-quote-or-not-quote-if-quote-then-what-quoting/m-p/637957#M189690</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-04-06T22:48:57Z</dc:date>
    </item>
  </channel>
</rss>

