<?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 Help using a date in single quotes using sysdate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93574#M257559</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Any help would be much appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to automate a report that runs monthly, with a one month 'lag' and creates a variable in where the values are in single quotes.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, for example, if I run the report today, it creates a variable that reads '01MAY2013' single quotes included.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am able to create the macro variable that creates the variable by creating this:&lt;/P&gt;&lt;P&gt;%let report_month =%sysfunc(intx(month.1,"&amp;amp;sysdate"d,-1),MonYY7.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i just can't figure it out how to get the date in&amp;nbsp; quotes such that it in the format '01MAY2013' d.&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>Mon, 03 Jun 2013 14:45:45 GMT</pubDate>
    <dc:creator>DSF</dc:creator>
    <dc:date>2013-06-03T14:45:45Z</dc:date>
    <item>
      <title>Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93574#M257559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Any help would be much appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to automate a report that runs monthly, with a one month 'lag' and creates a variable in where the values are in single quotes.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, for example, if I run the report today, it creates a variable that reads '01MAY2013' single quotes included.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am able to create the macro variable that creates the variable by creating this:&lt;/P&gt;&lt;P&gt;%let report_month =%sysfunc(intx(month.1,"&amp;amp;sysdate"d,-1),MonYY7.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i just can't figure it out how to get the date in&amp;nbsp; quotes such that it in the format '01MAY2013' d.&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>Mon, 03 Jun 2013 14:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93574#M257559</guid>
      <dc:creator>DSF</dc:creator>
      <dc:date>2013-06-03T14:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93575#M257560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How are you using the Report_month variable? If you leave off the &lt;SPAN style="text-decoration: underline;"&gt;,Monyy7&lt;/SPAN&gt;. in the %sysfunc call then you have the actual value that '01May2013'd represents and don't need to mess with any quotes at all. You would be able to for instance:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If testdate le &amp;amp;Report_month;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Jun 2013 15:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93575#M257560</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-06-03T15:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93576#M257561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are using in just with SAS (as a date literal for instance) then you can just use double quotes instead of single quotes. "13MAY2013"d works just as well as '13MAY2013'd.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;%let report_month ="%sysfunc(intx(month.1,"&amp;amp;sysdate9"d,-1),date9.)"d ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you really need to add single quotes around a macro variable value there are a few ways.&lt;/P&gt;&lt;P&gt;You could use macro quoting to get the single quotes without blocking the macro expansion.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %str(%')&amp;amp;sysdate9%str(%');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could also use the DEQUOTE() function and fact that you can embed single quotes within double quotes and still get macro expansion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %sysfunc(dequote("'&amp;amp;sysdate9'")) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Jun 2013 15:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93576#M257561</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-06-03T15:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93577#M257562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks ballardw,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure that works though.&amp;nbsp; I should have mentioned that I need the variable to be the first day of the previous month.&amp;nbsp; so, if i were to run it july 4, 2013 for example, it would read '01JUN2013'.&amp;nbsp; I have to run it this way to conform to the rest of the code in the report unfortunately.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jun 2013 00:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93577#M257562</guid>
      <dc:creator>DSF</dc:creator>
      <dc:date>2013-06-04T00:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93578#M257563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I actually need not just the sysdate, but the first day of the previous month relative to sysdate,&amp;nbsp; in single quotes to conform with how the code is set to run now.&amp;nbsp; so for example, if i were to run it july 4, 2013 for example, it would read '01JUN2013'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jun 2013 00:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93578#M257563</guid>
      <dc:creator>DSF</dc:creator>
      <dc:date>2013-06-04T00:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93579#M257564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right, so just do that, you already had the function in your original post, just the wrong output format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;%let report_month =%sysfunc(dequote("'%sysfunc(intnx(month.1,"&amp;amp;sysdate9"d,-1),date9.)'"));&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jun 2013 01:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93579#M257564</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-06-04T01:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93580#M257565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are needing to wrap multiple dates in single quotes, you might prefer to define specific macro functions to achieve this aim.&amp;nbsp; A while ago I wrote a paper on how to do this.&amp;nbsp; Macro functions can simplify your code but be sure to compile them or include them in your autolib option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jun 2013 09:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93580#M257565</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-06-04T09:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93581#M257566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom has already given you the solution for creating a macro variable value in the form you asked for which was: '01MAY2013' d&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume you then want to use the macro variable in your code in a way like: where date=&amp;amp;report_month&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so then you could also populate the macro variable with a SAS date value instead of an expression which then resolves into a SAS date value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following this thought something like below would do the job as well:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;%let report_month =&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;(intnx(month,"&amp;amp;sysdate9"d,-1,b));&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jun 2013 10:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93581#M257566</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-06-04T10:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93582#M257567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome, thanks Tom!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jun 2013 16:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93582#M257567</guid>
      <dc:creator>DSF</dc:creator>
      <dc:date>2013-06-04T16:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help using a date in single quotes using sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93583#M257568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cool, thanks Richard!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jun 2013 16:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-a-date-in-single-quotes-using-sysdate/m-p/93583#M257568</guid>
      <dc:creator>DSF</dc:creator>
      <dc:date>2013-06-04T16:27:32Z</dc:date>
    </item>
  </channel>
</rss>

