<?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: How to resolve a macro variable with single quotes around in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211200#M39109</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To single quote a string you would need something like: where date_string=%unquote(%str(%')&amp;amp;&lt;SPAN style="font-family: 'courier new', courier; font-size: 13px; background-color: #ffffff;"&gt;today&lt;/SPAN&gt;%str(%'))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're running this in-database and I would assume column "date" is actually of type date/datetime. If so then I would assume you don't have to pass-in your value as a character string but as something the data base can treat as a date value. How exactly to pass in the value depends on the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming it's SQL Server it would be something like:&amp;nbsp; where date=cast(&lt;SPAN style="font-size: 13.3333330154419px;"&gt;%unquote(%str(%')&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 13px; background-color: #ffffff;"&gt;today&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;%str(%')) as datetime)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....but then: Instead of using a SAS Date function and then convert it to a SQL Server date value in a pass-through block you could also directly use a SQL Server Date function &lt;A class="active_link" href="http://www.w3schools.com/sql/sql_dates.asp" title="http://www.w3schools.com/sql/sql_dates.asp"&gt;Date Functions in SQL Server and MySQL &lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Jun 2015 11:59:27 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2015-06-22T11:59:27Z</dc:date>
    <item>
      <title>How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211197#M39106</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;I have a date value with out single quotes. I am hooking into sql and filtering the data using where statement. But the macro variable seems to be not working. I am sure that the probolem is the date does not have single quotes.&lt;BR /&gt;Is there a macro function that resolves the macro variable with quotes, here is my code below:&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; %macro Loop;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let today&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = %sysfunc(today(),yymmdd10.);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; proc sql exec;&lt;BR /&gt;&amp;nbsp; connect to odbc (&amp;amp;connectA);&lt;/P&gt;&lt;P&gt; SELECT *&lt;BR /&gt;&amp;nbsp; FROM connection to odbc&lt;BR /&gt;(&lt;BR /&gt;&amp;nbsp; SELECT count(*) as row_count FROM [xxxxx].[xxxx].[xxxxx]&amp;nbsp; A WITH (NOLOCK)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE date = "&amp;amp;today"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; );&lt;BR /&gt;&amp;nbsp; disconnect from odbc;&lt;BR /&gt;quit; &lt;BR /&gt;%mend &lt;/P&gt;&lt;P&gt;macro varible date resolves to 2015-06-22 but I want the date in single quotes('2015-06-22') How can I do that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 10:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211197#M39106</guid>
      <dc:creator>KiranMaddi</dc:creator>
      <dc:date>2015-06-22T10:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211198#M39107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just add single quotes: &lt;SPAN style="font-family: courier new,courier;"&gt;WHERE date = "'&amp;amp;today'"&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 11:30:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211198#M39107</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2015-06-22T11:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211199#M39108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andreas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tried your suggestion. seems not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: CLI describe error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid column name &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 12pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ''2015-06-16''. : [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement(s) could not &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 12pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; be prepared.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 11:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211199#M39108</guid>
      <dc:creator>KiranMaddi</dc:creator>
      <dc:date>2015-06-22T11:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211200#M39109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To single quote a string you would need something like: where date_string=%unquote(%str(%')&amp;amp;&lt;SPAN style="font-family: 'courier new', courier; font-size: 13px; background-color: #ffffff;"&gt;today&lt;/SPAN&gt;%str(%'))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're running this in-database and I would assume column "date" is actually of type date/datetime. If so then I would assume you don't have to pass-in your value as a character string but as something the data base can treat as a date value. How exactly to pass in the value depends on the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming it's SQL Server it would be something like:&amp;nbsp; where date=cast(&lt;SPAN style="font-size: 13.3333330154419px;"&gt;%unquote(%str(%')&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 13px; background-color: #ffffff;"&gt;today&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;%str(%')) as datetime)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....but then: Instead of using a SAS Date function and then convert it to a SQL Server date value in a pass-through block you could also directly use a SQL Server Date function &lt;A class="active_link" href="http://www.w3schools.com/sql/sql_dates.asp" title="http://www.w3schools.com/sql/sql_dates.asp"&gt;Date Functions in SQL Server and MySQL &lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 11:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211200#M39109</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-06-22T11:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211201#M39110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if it could work on Pass-through.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H3&gt;Code: Program&lt;/H3&gt;&lt;PRE class="sce-render" style="font-family: 'Courier New', Menlo, 'Lucida Console'; font-size: 16px;"&gt;&lt;SPAN class="text" style="color: black;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="macro-keyword" style="color: #0000ff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;today&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="macro-keyword" style="color: #0000ff;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;today&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="format" style="color: #008080;"&gt;yymmdd10.&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="macro-keyword" style="color: #0000ff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;fix&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="macro-keyword" style="color: #0000ff;"&gt;%unquote&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="macro-keyword" style="color: #0000ff;"&gt;%str&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;%'&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;today&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;%'&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;options&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;symbolgen&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;proc&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;sql&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;select&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;*&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;from&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;sashelp.class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;where&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;name&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;fix&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;quit&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;H3&gt;Log: Program&lt;/H3&gt;&lt;P&gt;Notes (2)&lt;/P&gt;&lt;DIV class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;P&gt;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; SYMBOLGEN: Macro variable _SASWSTEMP_ resolves to /folders/myfolders/.images/d68a90fb-ff4b-4300-be59-7d1dc90f4a3b&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; SYMBOLGEN: Macro variable GRAPHINIT resolves to&amp;nbsp; &lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 57&amp;nbsp; &lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 58 %let today= %sysfunc(today(),yymmdd10.);&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 59 %let fix=%unquote(%str(%'&amp;amp;today%'));&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; SYMBOLGEN: Macro variable TODAY resolves to 2015-06-22&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 60 options symbolgen;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 61 proc sql;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 62 select *&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 63 from sashelp.class&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 64 where name= &amp;amp;fix ;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; SYMBOLGEN: Macro variable FIX resolves to '2015-06-22'&lt;/P&gt;&lt;P class="sasNote" id="sasLogNote1_1434974865014" style="color: #0000ff; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; NOTE: No rows were selected.&lt;/P&gt;&lt;P class="sasSource" style="color: #000000; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; 65 quit;&lt;/P&gt;&lt;P class="sasNote" id="sasLogNote2_1434974865014" style="color: #0000ff; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt; NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P class="sasNote" style="color: #0000ff; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt;&amp;nbsp; real time 0.11 seconds&lt;/P&gt;&lt;P class="sasNote" style="color: #0000ff; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt;&amp;nbsp; cpu time 0.10 seconds&lt;/P&gt;&lt;P class="sasNote" style="color: #0000ff; font-family: monospace; font-size: 14px; background-color: #f0f1f2;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 12:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211201#M39110</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-06-22T12:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211202#M39111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excellent stuff Patrick!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot. Both are working but I am going with the first one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 12:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211202#M39111</guid>
      <dc:creator>KiranMaddi</dc:creator>
      <dc:date>2015-06-22T12:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211203#M39112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks buddy! &lt;STRONG&gt;But that is not working on pass through&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 12:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211203#M39112</guid>
      <dc:creator>KiranMaddi</dc:creator>
      <dc:date>2015-06-22T12:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211204#M39113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I faced actually not too long ago exactly the same problem and I had a lot of cases where I needed single quoting of macro variables. I ended up with implementing a function style macro (stored in a folder which is part of the Autocall facility).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here the code and how it's used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro util_quote_val(&lt;/P&gt;&lt;P&gt;&amp;nbsp; in_string,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* source string to be quoted&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&amp;nbsp; not_NULL_flg&amp;nbsp;&amp;nbsp; /* if empty source string: return two quotes instead of NULL&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&amp;nbsp; );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if %bquote(&amp;amp;in_string)=%bquote() %then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %bquote(&amp;amp;not_NULL_flg)=%bquote() %then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %str(NULL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %str('')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %unquote(%str(%')%trim(%left(&amp;amp;in_string))%str(%'))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let name=Alfred;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select *&lt;/P&gt;&lt;P&gt;&amp;nbsp; from sashelp.class&lt;/P&gt;&lt;P&gt;&amp;nbsp; where name=%util_quote_val(&amp;amp;name,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....and if you've got your solution then can you please mark the answers as helpful and correct? Especially the correct "helps us" to concentrate on questions which still require a solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 12:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211204#M39113</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-06-22T12:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211205#M39114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have actually clicked on your answer as correct as soon as the code worked for me and somehow it did not register my click.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ways thanks for you great help:-)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 12:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211205#M39114</guid>
      <dc:creator>KiranMaddi</dc:creator>
      <dc:date>2015-06-22T12:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211206#M39115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks all for your help. Really appreciated :smileylaugh:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 12:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211206#M39115</guid>
      <dc:creator>KiranMaddi</dc:creator>
      <dc:date>2015-06-22T12:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211207#M39116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick sorry for asking a question on a closed discussion. How do I add parenthesis as well around a macro variable. something like this?&lt;/P&gt;&lt;P&gt;I want to see &amp;amp;today like this&amp;nbsp; ('&amp;amp;today')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where date_string=%unquote(%str(%'()&amp;amp;&lt;SPAN style="font-family: 'courier new', courier; font-size: 13px; background-color: #ffffff;"&gt;today&lt;/SPAN&gt;%str(%')))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 07:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211207#M39116</guid>
      <dc:creator>KiranMaddi</dc:creator>
      <dc:date>2015-06-25T07:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211208#M39117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like below should work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let today = %sysfunc(today(),yymmdd10.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put where date_string=(%unquote(%str(%')&amp;amp;today%str(%')));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 08:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211208#M39117</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-06-25T08:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211209#M39118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;where date_string=%unquote(%str(%'%()&amp;amp;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;today&lt;/SPAN&gt;%str(%'%)))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 12:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211209#M39118</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-06-25T12:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211210#M39119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is simple solution for adding single quotes.&amp;nbsp; Not sure why you would want to remove the leading and trailing spaces that someone would actually have to work pretty hard to get passed into the macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%macro squote(value);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%unquote(%str(%')%qsysfunc(tranwrd(%superq(value),%str(%'),''))%str(%'))&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%mend squote;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 14:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211210#M39119</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-06-25T14:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve a macro variable with single quotes around</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211211#M39120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;Not sure why you would want to remove the leading and trailing spaces&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;The macro I've posted was from a real implementation and there it made sense to remove such blanks should they ever occur. Most of the logic in the macro is actually about replacing empty input strings with either two quotes or keyword NULL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 21:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-a-macro-variable-with-single-quotes-around/m-p/211211#M39120</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-06-25T21:34:43Z</dc:date>
    </item>
  </channel>
</rss>

