<?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 Macro execution when macro variables contain special characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78647#M17012</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having a problem with a macro I'm trying to write to display titles in a sas template&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the macro goes as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step one: compile macro variables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select count(distinct titles)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from bigset;&lt;/P&gt;&lt;P&gt;select distinct titles&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :%nrstr(titlemacr1) - :%nrstr(titlemacr%left(&amp;amp;n))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from bigset;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step II:&amp;nbsp; Execute a macro to generate graphs with a unique title as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro titleloop;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc template;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entrytitle %sysfunc(%nrquote("&amp;amp;&amp;amp;titlemacr&amp;amp;i");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%titleloop;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem i'm having is that the entrytitle statement will not resolve if the string which &amp;amp;&amp;amp;titlemacr&amp;amp;i resolves to contains any quotes.&amp;nbsp; For example, if titlemacr resolves to ABCD, the macro is fine.&amp;nbsp; if titlemacr resolves to ABC"D the macro generates an error and does not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I going about the sysfunc/nrquote functions incorrectly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Sep 2013 13:24:53 GMT</pubDate>
    <dc:creator>bullman</dc:creator>
    <dc:date>2013-09-11T13:24:53Z</dc:date>
    <item>
      <title>Macro execution when macro variables contain special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78647#M17012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having a problem with a macro I'm trying to write to display titles in a sas template&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the macro goes as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step one: compile macro variables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select count(distinct titles)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from bigset;&lt;/P&gt;&lt;P&gt;select distinct titles&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :%nrstr(titlemacr1) - :%nrstr(titlemacr%left(&amp;amp;n))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from bigset;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step II:&amp;nbsp; Execute a macro to generate graphs with a unique title as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro titleloop;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc template;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entrytitle %sysfunc(%nrquote("&amp;amp;&amp;amp;titlemacr&amp;amp;i");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%titleloop;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem i'm having is that the entrytitle statement will not resolve if the string which &amp;amp;&amp;amp;titlemacr&amp;amp;i resolves to contains any quotes.&amp;nbsp; For example, if titlemacr resolves to ABCD, the macro is fine.&amp;nbsp; if titlemacr resolves to ABC"D the macro generates an error and does not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I going about the sysfunc/nrquote functions incorrectly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 13:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78647#M17012</guid>
      <dc:creator>bullman</dc:creator>
      <dc:date>2013-09-11T13:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro execution when macro variables contain special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78648#M17013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use QUOTE function something like this untested&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; entrytitle %sysfunc(quote(%superq(titlemacr&amp;amp;i)));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 13:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78648#M17013</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-09-11T13:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro execution when macro variables contain special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78649#M17014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That didn't quote work -- I still receive an error along the lines of 'the function quote referenced by %sysfunc has too many arguments&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro variable in question has a double quotes attached to two numbers followed by blank space.&amp;nbsp; It seems like the function tries to resolve when it sees that quote, and that's where the issue beings.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 13:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78649#M17014</guid>
      <dc:creator>bullman</dc:creator>
      <dc:date>2013-09-11T13:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro execution when macro variables contain special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78650#M17015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should check that PROC TEMPLATE handles these characters properly by creating an example without macro logic or macro variables.&amp;nbsp; For example if TITLEMACR1 contains ABC"D then you would want to test if&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; entrytitle "ABC""D" ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: You can simplify the SQL that is generating the macro variables.&amp;nbsp; You can also put the call to QUOTE() function there and avoid issues with macro variable expansions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select distinct &lt;STRONG&gt;quote(trim(&lt;/STRONG&gt;titles&lt;STRONG&gt;))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :titlemacr1 - :titlemacr99999&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from bigset&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let n=&amp;amp;sqlobs ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; entrytitle &amp;amp;&amp;amp;title1macr&amp;amp;i ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 14:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78650#M17015</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-09-11T14:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro execution when macro variables contain special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78651#M17016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Still not quite working, however the template does resolve if there are quotes within quotes, e.g. entrytitle "ABC""D" does resolve.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further, if i try out the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;entrytitle %sysfunc(quote(%bquote(&amp;amp;title34)));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the macro resolves, too.&amp;nbsp; it apepars that the double pass of the macro creates an issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 15:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78651#M17016</guid>
      <dc:creator>bullman</dc:creator>
      <dc:date>2013-09-11T15:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro execution when macro variables contain special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78652#M17017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;%bquote(&amp;amp;title34)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;works then&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;%superq(title34) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;should also work and so should &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'courier new', courier;"&gt;%superq(title&amp;amp;i)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 15:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-execution-when-macro-variables-contain-special-characters/m-p/78652#M17017</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-09-11T15:17:30Z</dc:date>
    </item>
  </channel>
</rss>

