<?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: Quote the quotes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Quote-the-quotes/m-p/179486#M34298</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;O.K. - this was now ridiculously hard to work out. But at least I believe I've got it now. I normally don't mark my own answer as "correct" but this time I feel I deserve a treat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let have = %nrquote(Peter &amp;amp; Paul%'s label);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro codegen;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let label=%str(%')%qsysfunc(transtrn(&amp;amp;have,%str(%'),%str(%'%')))%str(%');&lt;/P&gt;&lt;P&gt;&amp;nbsp; data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib var length=8 label=%unquote(&amp;amp;label);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%codegen;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;MPRINT(CODEGEN):&amp;nbsp;&amp;nbsp; data want;&lt;/P&gt;&lt;P&gt;MPRINT(CODEGEN):&amp;nbsp;&amp;nbsp; attrib var length=8 label='Peter &amp;amp; Paul''s label';&lt;/P&gt;&lt;P&gt;MPRINT(CODEGEN):&amp;nbsp;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;MPRINT(CODEGEN):&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Feb 2015 12:54:06 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2015-02-25T12:54:06Z</dc:date>
    <item>
      <title>Quote the quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-the-quotes/m-p/179485#M34297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to implement a SAS macro which generates a data step attrib statement. The problem comes from a real life scenario where I want to automate table creation based on SAS DI Studio 4.9 generated code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "%let have" statement is a representation of the auto-generated code bit so this statement is a given and can't be modified.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The %let statement will be auto-generated and no modification is possible.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%let have = %nrquote(Peter &amp;amp; Paul%'s label);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I can implement whatever macro code I want. Below does not work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&amp;nbsp; so the code posted is where I am right now and got stuck.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro codegen;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %let label=%sysfunc(transtrn(&amp;amp;have,%nrquote(%'),%nrquote(%'%'))); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib var length=8 label=%nrquote(%')%str(&amp;amp;label)%nrquote(%');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; run;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%codegen;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;And here what I would like the macro to return. This code works if executed on its own.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; attrib var length=8 label='Peter &amp;amp; Paul&lt;STRONG&gt;''&lt;/STRONG&gt;s label';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; stop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My environment is SAS9.4 M2 under RHEL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2015 06:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-the-quotes/m-p/179485#M34297</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-02-24T06:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Quote the quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quote-the-quotes/m-p/179486#M34298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;O.K. - this was now ridiculously hard to work out. But at least I believe I've got it now. I normally don't mark my own answer as "correct" but this time I feel I deserve a treat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let have = %nrquote(Peter &amp;amp; Paul%'s label);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro codegen;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let label=%str(%')%qsysfunc(transtrn(&amp;amp;have,%str(%'),%str(%'%')))%str(%');&lt;/P&gt;&lt;P&gt;&amp;nbsp; data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib var length=8 label=%unquote(&amp;amp;label);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%codegen;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;MPRINT(CODEGEN):&amp;nbsp;&amp;nbsp; data want;&lt;/P&gt;&lt;P&gt;MPRINT(CODEGEN):&amp;nbsp;&amp;nbsp; attrib var length=8 label='Peter &amp;amp; Paul''s label';&lt;/P&gt;&lt;P&gt;MPRINT(CODEGEN):&amp;nbsp;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;MPRINT(CODEGEN):&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 12:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quote-the-quotes/m-p/179486#M34298</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-02-25T12:54:06Z</dc:date>
    </item>
  </channel>
</rss>

