<?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: Single and double quote combinations inside a macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506686#M135820</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/145776"&gt;@Top_Katz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you, Astounding Super User, that's a useful work around.&amp;nbsp; It's not exactly what I wanted, because I have to pass the string that takes the place of '/home/image.jpg' all inside single quotes, which means I may have to pass it twice, both in and out of the single quotes.&amp;nbsp; But it&amp;nbsp;keeps me going until I find a way to get the macro variable between the single quotes inside the macro code.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I may not completely understand all the issues but I like to let SAS do then quoting when that are quotes within quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;457  %let cstr = %str(^S={preimage="/home/image.jpg"});
458  %put NOTE: CHECK: %sysfunc(quote(%superq(cstr)));
NOTE: CHECK: "^S={preimage=""/home/image.jpg""}"
459  ods pdf text=%sysfunc(quote(%superq(cstr)));
NOTE: Writing ODS PDF output to DISK destination "sasprt.pdf", printer "PDF".
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 Oct 2018 21:52:12 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2018-10-22T21:52:12Z</dc:date>
    <item>
      <title>Single and double quote combinations inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506596#M135816</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am editing a macro with the following line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods pdf text='^S={preimage="/home/image.jpg"}';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works as is, but I need to replace the hard-coded string "/home/image.jpg" with a macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can get the following to work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let cstr = %str(&lt;SPAN&gt;'^S={preimage="/home/image.jpg"}');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ods pdf text=&amp;amp;cstr.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but if I try:&lt;/P&gt;&lt;P&gt;%let cstr = %str(&lt;SPAN&gt;^S={preimage="/home/image.jpg"});&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ods pdf text=%str(%')&amp;amp;cstr.&lt;SPAN&gt;%str(%')&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get an error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;355 ods pdf text='&amp;amp;cstr.';&lt;BR /&gt;_&lt;BR /&gt;22&lt;BR /&gt;_&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Expecting a quoted string.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get this to resolve properly inside a macro?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 20:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506596#M135816</guid>
      <dc:creator>Top_Katz</dc:creator>
      <dc:date>2018-10-22T20:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Single and double quote combinations inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506598#M135817</link>
      <description>&lt;P&gt;Use single quotes on the inside, and double quotes on the outside:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let cstr = %str(&lt;SPAN&gt;^S={preimage='/home/image.jpg'});&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;ods pdf text="&amp;amp;cstr.";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Single quotes suppress all macro activity.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 20:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506598#M135817</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-22T20:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Single and double quote combinations inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506660#M135818</link>
      <description>&lt;P&gt;Thank you, Astounding Super User, that's a useful work around.&amp;nbsp; It's not exactly what I wanted, because I have to pass the string that takes the place of '/home/image.jpg' all inside single quotes, which means I may have to pass it twice, both in and out of the single quotes.&amp;nbsp; But it&amp;nbsp;keeps me going until I find a way to get the macro variable between the single quotes inside the macro code.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 20:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506660#M135818</guid>
      <dc:creator>Top_Katz</dc:creator>
      <dc:date>2018-10-22T20:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Single and double quote combinations inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506686#M135820</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/145776"&gt;@Top_Katz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you, Astounding Super User, that's a useful work around.&amp;nbsp; It's not exactly what I wanted, because I have to pass the string that takes the place of '/home/image.jpg' all inside single quotes, which means I may have to pass it twice, both in and out of the single quotes.&amp;nbsp; But it&amp;nbsp;keeps me going until I find a way to get the macro variable between the single quotes inside the macro code.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I may not completely understand all the issues but I like to let SAS do then quoting when that are quotes within quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;457  %let cstr = %str(^S={preimage="/home/image.jpg"});
458  %put NOTE: CHECK: %sysfunc(quote(%superq(cstr)));
NOTE: CHECK: "^S={preimage=""/home/image.jpg""}"
459  ods pdf text=%sysfunc(quote(%superq(cstr)));
NOTE: Writing ODS PDF output to DISK destination "sasprt.pdf", printer "PDF".
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Oct 2018 21:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506686#M135820</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-22T21:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Single and double quote combinations inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506715#M135823</link>
      <description>&lt;P&gt;OK, here's&amp;nbsp; another workaround that you can play with, finding the right spot(s) to use it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ods pdf text=%unquote(%str(%')&amp;amp;cstr.%str(%'));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 02:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506715#M135823</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-23T02:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Single and double quote combinations inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506811#M135878</link>
      <description>Thank you, Respected Advisor data_null__, that worked!</description>
      <pubDate>Tue, 23 Oct 2018 13:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506811#M135878</guid>
      <dc:creator>Top_Katz</dc:creator>
      <dc:date>2018-10-23T13:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Single and double quote combinations inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506812#M135879</link>
      <description>Thank you, Astounding Super User, that worked!</description>
      <pubDate>Tue, 23 Oct 2018 13:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506812#M135879</guid>
      <dc:creator>Top_Katz</dc:creator>
      <dc:date>2018-10-23T13:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Single and double quote combinations inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506823#M135884</link>
      <description>&lt;P&gt;I don't think this is a situation where you need to use single quotes instead of double quotes since you are just generating SAS code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when you do need single quotes (for example in pass thru SQL code) then I like to use an %SQUOTE() macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one that will work even if you are still running older versions of SAS.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/sasutils/macros/blob/master/squote.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/squote.sas&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro squote(value);
%if %sysevalf(&amp;amp;sysver &amp;lt; 9.3) %then
%unquote(%str(%')%qsysfunc(tranwrd(%superq(value),%str(%'),''))%str(%'))
;
%else %sysfunc(quote(%superq(value),%str(%'))) ;
%mend squote;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 13:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-and-double-quote-combinations-inside-a-macro/m-p/506823#M135884</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-23T13:55:36Z</dc:date>
    </item>
  </channel>
</rss>

