<?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 do I single quote a variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49354#M10220</link>
    <description>Hi Patrick&lt;BR /&gt;
&lt;BR /&gt;
%put ***********************************************;&lt;BR /&gt;
%let MCV_END_DATE='23Sep08'd;&lt;BR /&gt;
%put That is not a SAS date: &amp;amp;MCV_END_DATE;&lt;BR /&gt;
%put The SAS macro compiler deals with text only;&lt;BR /&gt;
&lt;BR /&gt;
%put ***********************************************;&lt;BR /&gt;
%let MCV_END_DATE=%sysfunc(inputn('23Sep08',date9.));&lt;BR /&gt;
%put THAT is text with digits representing the days since 1/1/1960: &amp;amp;MCV_END_DATE;&lt;BR /&gt;
&lt;BR /&gt;
%put ***********************************************;&lt;BR /&gt;
%let MCV_END_DATE=%str(%')%sysfunc(inputn('23Sep08',date9.),is8601da.)%str(%');&lt;BR /&gt;
%put That is may be what you are looking for: &amp;amp;MCV_END_DATE;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
    <pubDate>Wed, 24 Sep 2008 11:10:25 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2008-09-24T11:10:25Z</dc:date>
    <item>
      <title>how do I single quote a variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49351#M10217</link>
      <description>Howdy.&lt;BR /&gt;
I'm bringing in a SAS date value that I must convert to standard date format for use in a Teradata SQL statement.  I need to put single quotes around this date.&lt;BR /&gt;
How can I do this?&lt;BR /&gt;
my ending SQL statement would be something like:&lt;BR /&gt;
Select * From some_table where mydate = '2008-09-08'&lt;BR /&gt;
&lt;BR /&gt;
Example code:&lt;BR /&gt;
&lt;BR /&gt;
%macro mcvDateFormat;&lt;BR /&gt;
%let MCV_END_DATE='23Sept08'd&lt;BR /&gt;
	%if %length(&amp;amp;MCV_END_DATE) &amp;gt; 1 %then&lt;BR /&gt;
	%do;&lt;BR /&gt;
	  %if %length(&amp;amp;MCV_END_DATE)=9 %then&lt;BR /&gt;
			%do;&lt;BR /&gt;
				%let mcv_request_end=%sysfunc(inputn(&amp;amp;MCV_END_DATE,date9.0));&lt;BR /&gt;
				%put We are using date 9;&lt;BR /&gt;
			%end;&lt;BR /&gt;
		%else %if	%length(&amp;amp;MCV_END_DATE)=10 %then&lt;BR /&gt;
			%do;&lt;BR /&gt;
				%let mcv_request_end=%sysfunc(inputn(&amp;amp;MCV_END_DATE,mmddyy10.));&lt;BR /&gt;
				%put We are using mmddyy 10  &amp;amp;mcv_request_end;&lt;BR /&gt;
			%end;&lt;BR /&gt;
		%else&lt;BR /&gt;
			%do;&lt;BR /&gt;
				%let mcv_request_end=%sysfunc(putn(&amp;amp;MCV_END_DATE, is8601da.));&lt;BR /&gt;
				%put We have a SAS date so we convert to iso date  &amp;amp;mcv_request_end;&lt;BR /&gt;
			%end;&lt;BR /&gt;
&lt;BR /&gt;
	%end;&lt;BR /&gt;
&lt;BR /&gt;
/* try to quote date here */&lt;BR /&gt;
%let test ='&amp;amp;mcv_request_end';&lt;BR /&gt;
%put &amp;amp;test;&lt;BR /&gt;
&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
 %mcvDateFormat;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank you&lt;BR /&gt;
Patrick</description>
      <pubDate>Tue, 23 Sep 2008 20:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49351#M10217</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-23T20:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: how do I single quote a variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49352#M10218</link>
      <description>Patrick, &lt;BR /&gt;
&lt;BR /&gt;
There are multiple ways how one can accomplish this. When using macros you can use &lt;BR /&gt;
%str function that removes meaning from special characters (not all of them!). I suggest you read up on the function.&lt;BR /&gt;
&lt;BR /&gt;
here is the example: &lt;BR /&gt;
&lt;BR /&gt;
%let mcv_request_end=23SEP08;&lt;BR /&gt;
&lt;BR /&gt;
%let mcv_request_end=&lt;B&gt;%str&lt;/B&gt;(&lt;B&gt;%'&lt;/B&gt;&amp;amp;mcv_request_end&lt;B&gt;%'&lt;/B&gt;);&lt;BR /&gt;
%put &amp;amp;mcv_request_end;&lt;BR /&gt;
&lt;BR /&gt;
ikp</description>
      <pubDate>Tue, 23 Sep 2008 22:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49352#M10218</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-23T22:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: how do I single quote a variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49353#M10219</link>
      <description>Are you using SQL pass-thru? If not, I believe that you could use a SAS date literal, which SAS/ACCESS engine will convert automatically to a Teradata data value:&lt;BR /&gt;
&lt;BR /&gt;
Select * From some_table where mydate = &amp;amp;MVC_END_DATE;&lt;BR /&gt;
&lt;BR /&gt;
If using pass-thru, I think the easiest way is to create your macro variable in a data step:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%let MCV_END_DATE='23Sep08'd;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
	call symput('MCV_REQUEST_END',"'"||put(&amp;amp;MCV_END_DATE,yymmdd10.)||"'");&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
      <pubDate>Wed, 24 Sep 2008 06:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49353#M10219</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-09-24T06:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: how do I single quote a variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49354#M10220</link>
      <description>Hi Patrick&lt;BR /&gt;
&lt;BR /&gt;
%put ***********************************************;&lt;BR /&gt;
%let MCV_END_DATE='23Sep08'd;&lt;BR /&gt;
%put That is not a SAS date: &amp;amp;MCV_END_DATE;&lt;BR /&gt;
%put The SAS macro compiler deals with text only;&lt;BR /&gt;
&lt;BR /&gt;
%put ***********************************************;&lt;BR /&gt;
%let MCV_END_DATE=%sysfunc(inputn('23Sep08',date9.));&lt;BR /&gt;
%put THAT is text with digits representing the days since 1/1/1960: &amp;amp;MCV_END_DATE;&lt;BR /&gt;
&lt;BR /&gt;
%put ***********************************************;&lt;BR /&gt;
%let MCV_END_DATE=%str(%')%sysfunc(inputn('23Sep08',date9.),is8601da.)%str(%');&lt;BR /&gt;
%put That is may be what you are looking for: &amp;amp;MCV_END_DATE;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 24 Sep 2008 11:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49354#M10220</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-09-24T11:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: how do I single quote a variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49355#M10221</link>
      <description>Thanks so much everyone!  And you are correct Linus, I'm doing a SQL Pass-thru</description>
      <pubDate>Wed, 24 Sep 2008 12:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49355#M10221</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-24T12:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: how do I single quote a variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49356#M10222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;when supplying macro variables to teradata that need to be surrounded by single quotes,&amp;nbsp; i use the %bquote(&amp;amp;macrovar) if the macro variable has the quote marks included as LinusH does with the symput statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the other use of %bquote('&amp;amp;macrovar') is to supply the single quotes inside the parentheses with the macrovar name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Nov 2012 18:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-single-quote-a-variable/m-p/49356#M10222</guid>
      <dc:creator>tomg_highmark</dc:creator>
      <dc:date>2012-11-29T18:54:46Z</dc:date>
    </item>
  </channel>
</rss>

