<?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: macro to extract monthly report in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444052#M28703</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137395"&gt;@bondtk&lt;/a&gt; wrote:&lt;BR /&gt;Hi&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply, please advise if I want to run it for 3 months or 6 months extract , how do I change it, please advise , I am not good with macros...&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Tk&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Supply a startmonth and endmonth as macro parameters, and then compare datepart() of your timestamps with both&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where mdy(&amp;amp;startmonth,1,&amp;amp;startyear) &amp;lt;= datepart(d_entry) &amp;lt;= intnx('month',mdy(&amp;amp;endmonth,1,&amp;amp;endyear),0,'e');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Mar 2018 06:46:49 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-03-12T06:46:49Z</dc:date>
    <item>
      <title>macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443211#M28617</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have got this code to extract my data,&amp;nbsp; wondering if there is any macro possible so that it extracts monthly data and I don't have to&lt;/P&gt;&lt;P&gt;change dates all the time. Any macro possible so I can only select a month or just change month name in macro&amp;nbsp; extract monthly data,&lt;/P&gt;&lt;P&gt;please advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data application_extract;&lt;/P&gt;&lt;P&gt;set retail .xy_BBS_masterflow;&lt;/P&gt;&lt;P&gt;where d_entry &amp;gt;= '2016-11-01 00:00:00.000' and d_entry&amp;nbsp;&amp;lt; &amp;nbsp;'2017-10-01 00:00:00.000'&amp;nbsp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 08:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443211#M28617</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-03-07T08:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443213#M28618</link>
      <description>&lt;P&gt;Just an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input d_entry e8601dt24.3;
format d_entry e8601dt24.3;
cards;
2016-11-01 00:00:00.000
2016-11-02 00:00:00.000
2016-12-02 00:00:00.000
;
run;

%macro select(year,month);
data want;
set have;
where month(datepart(d_entry)) = &amp;amp;month and year(datepart(d_entry)) = &amp;amp;year;
run;
%mend;

%select(2016,11)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 08:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443213#M28618</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-07T08:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443288#M28630</link>
      <description>&lt;P&gt;Clearly, you will have to supply a year as well as a month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you always want an 11-month time period?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the code you posted work (meaning that d_entry is a character string)?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 13:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443288#M28630</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-07T13:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443542#M28665</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;11 month is not mandatory, it could be 3 months , 06 months or monthly extract so I am looking what will be easiest way to capture that in a macro...&lt;BR /&gt;&lt;BR /&gt;Please advise&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Mar 2018 22:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443542#M28665</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-03-07T22:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443630#M28681</link>
      <description>&lt;P&gt;Since the time period can vary, the user will need to pass both the starting point and the ending point.&amp;nbsp; This might be the macro call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%extract (start=2016-11, finish=2017-10)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Users will need to be educated about the FINISH month itself being excluded from the extracted data.&amp;nbsp; The macro definition might look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro extract (start=, finish=);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;data&amp;nbsp;application_extract;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set retail .xy_BBS_masterflow;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; where ("&amp;amp;start-01 00:00:00.000" &amp;lt;= d_entry&amp;nbsp;&amp;lt;&amp;nbsp; "&amp;amp;finish-01 00:00:00.000") ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;%mend extract;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are other styles that can be used, if the start and finish points would need to be utilized at other points within the same program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice that double-quotes are being used.&amp;nbsp; Single quotes cause an error, preventing macro variables from resolving into their assigned values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All in all, using macro language here doesn't save a ton of work.&amp;nbsp; You could even argue that the original program is just as good as the one that uses macro language.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 05:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/443630#M28681</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-08T05:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444043#M28701</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I tried this macro, it came up with error&lt;BR /&gt;&lt;BR /&gt;Error: where clause operator requires compatible variables.&lt;BR /&gt;&lt;BR /&gt;Please advise.&lt;BR /&gt;</description>
      <pubDate>Fri, 09 Mar 2018 10:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444043#M28701</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-03-09T10:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444050#M28702</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply, please advise if I want to run it for 3 months or 6 months extract , how do I change it, please advise , I am not good with macros...&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Tk&lt;BR /&gt;</description>
      <pubDate>Fri, 09 Mar 2018 11:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444050#M28702</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-03-09T11:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444052#M28703</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137395"&gt;@bondtk&lt;/a&gt; wrote:&lt;BR /&gt;Hi&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply, please advise if I want to run it for 3 months or 6 months extract , how do I change it, please advise , I am not good with macros...&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Tk&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Supply a startmonth and endmonth as macro parameters, and then compare datepart() of your timestamps with both&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where mdy(&amp;amp;startmonth,1,&amp;amp;startyear) &amp;lt;= datepart(d_entry) &amp;lt;= intnx('month',mdy(&amp;amp;endmonth,1,&amp;amp;endyear),0,'e');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 06:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444052#M28703</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-12T06:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444479#M28732</link>
      <description>&lt;P&gt;This is telling you that the original WHERE clause you posted was incorrect. &amp;nbsp;Most likely, you omitted the characters dt:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;where ("&amp;amp;start-01 00:00:00.000"dt &amp;lt;= d_entry&amp;nbsp;&amp;lt;&amp;nbsp; "&amp;amp;finish-01 00:00:00.000"dt) ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But I'm guessing here. &amp;nbsp;You'll have to take a look at your original program, take a properly working version, and show what it looks like. &amp;nbsp;Until then, macro language cannot help.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 22:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444479#M28732</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-10T22:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444513#M28742</link>
      <description>&lt;P&gt;Hi Astounding&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; extract (start=, finish=);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data tk.application_extract_jun_aug;&lt;/P&gt;&lt;P&gt;set sastrain.application_extract;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;where (&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"&amp;amp;start-01 00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;lt;= d_entry &amp;lt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"&amp;amp;finish-01 00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; extract;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;extract&lt;/I&gt;&lt;/STRONG&gt; (start=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2017&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;06&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, finish=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2017&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;08&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;came with error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Invalid date/time/datetime constant "2017-06-01 00:00:00.000"dt.&lt;/P&gt;&lt;P&gt;ERROR: Invalid date/time/datetime constant "2017-08-01 00:00:00.000"dt.&lt;/P&gt;&lt;P&gt;ERROR: Syntax error while parsing WHERE clause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please advise.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 03:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444513#M28742</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-03-11T03:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444515#M28743</link>
      <description>&lt;P&gt;worked without &amp;nbsp;macro&lt;/P&gt;&lt;P&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; tk.application_extract_jun_aug;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sastrain.application_extract;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; d_entry &amp;gt;= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"01JUN2017:00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; and d_entry &amp;lt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"01SEP2017:00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;***************************************&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;so what changes I could make&amp;nbsp;in the macro: as macro gives the error:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; extract (start=, finish=);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data tk.application_extract_jun_aug;&lt;/P&gt;&lt;P&gt;set sastrain.application_extract;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;where (&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"&amp;amp;start-01 00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;lt;= d_entry &amp;lt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"&amp;amp;finish-01 00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; extract;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;extract&lt;/I&gt;&lt;/STRONG&gt; (start=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2017&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;06&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, finish=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2017&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;08&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Invalid date/time/datetime constant "2017-06-01 00:00:00.000"dt.&lt;/P&gt;&lt;P&gt;ERROR: Invalid date/time/datetime constant "2017-08-01 00:00:00.000"dt.&lt;/P&gt;&lt;P&gt;ERROR: Syntax error while parsing WHERE clause.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 03:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444515#M28743</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-03-11T03:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444527#M28745</link>
      <description>&lt;P&gt;In a datetime literal, SAS always expects the date part to be written in the ddmmmyyyy format like 01jan1960.&lt;/P&gt;
&lt;P&gt;For most purposes, I prefer to store the raw, unformatted numerical values of dates or datetimes in macro variables, as they can be used in calculations and comparisons without any wrappers.&lt;/P&gt;
&lt;P&gt;If you need to use a date for comparison with a datetime, just multiply the raw value by 86400.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 09:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444527#M28745</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-11T09:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444547#M28746</link>
      <description>&lt;P&gt;I don't get it.&amp;nbsp; If this statement worked without macros, why would you want macros to construct a statement that looks different than this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;d_entry &amp;gt;=&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;"01JUN2017:00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and d_entry &amp;lt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;"01SEP2017:00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 14:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444547#M28746</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-11T14:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444571#M28748</link>
      <description>Hi Astounding&lt;BR /&gt;&lt;BR /&gt;I am confused now with your answer, so you are saying that I am trying to do something different with the macro,&lt;BR /&gt;&lt;BR /&gt;All I am trying to remove this long date format to simply write the month and year to run the extract.&lt;BR /&gt;&lt;BR /&gt;If you could suggest an option to achieve that, as I am hopeless with the macros..&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;TK&lt;BR /&gt;</description>
      <pubDate>Sun, 11 Mar 2018 18:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444571#M28748</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-03-11T18:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444646#M28753</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137395"&gt;@bondtk&lt;/a&gt; wrote:&lt;BR /&gt;Hi Astounding&lt;BR /&gt;&lt;BR /&gt;I am confused now with your answer, so you are saying that I am trying to do something different with the macro,&lt;BR /&gt;&lt;BR /&gt;All I am trying to remove this long date format to simply write the month and year to run the extract.&lt;BR /&gt;&lt;BR /&gt;If you could suggest an option to achieve that, as I am hopeless with the macros..&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;TK&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In your macro-less code, you supplied correct SAS datetime literals. In your macrotized code, you changed the format of the date in the datetime literals from ddmmmyyyy (as in 01jan1960) to yyyy-mm-dd (as in 1960-01-01), which is not recognized.&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro extract(start=,finish=);

data _null_;
call symputx('startmonth',put(dhms(input("&amp;amp;start.-01",yymmdd10.),0,0,0),best.));
call symputx('endmonth',put(dhms(input("&amp;amp;finish.-01",yymmdd10.),23,59,59),best.));
run;

data tk.application_extract_jun_aug;
set sastrain.application_extract;
where &amp;amp;startmonth &amp;lt;= d_entry &amp;lt;= &amp;amp;endmonth;
run;

%mend extract;

%extract(start=2017-06,finish=2017-08)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 06:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444646#M28753</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-12T06:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444679#M28755</link>
      <description>&lt;P&gt;Hi Kurt&lt;/P&gt;&lt;P&gt;Thanks for the solution, really appreciate that..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now i I am just trying to understand the code , &amp;nbsp;is symputx function is used to convert the date in to character value , &amp;nbsp;could you please&amp;nbsp;&lt;/P&gt;&lt;P&gt;elaborate the whole code step by step as I am not familiar with symputx, &amp;nbsp;put dims and the use input, &amp;nbsp;if you could help me understand this code then it will &amp;nbsp;be very beneficial for my learning. Please advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tk&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 09:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444679#M28755</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-03-12T09:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444683#M28756</link>
      <description>&lt;P&gt;First of all, symputx is not a &lt;EM&gt;function&lt;/EM&gt;, it is a &lt;EM&gt;call routine&lt;/EM&gt; (in Pascal such a thing is called a procedure, the generic name in programming is subroutine; C does not have it, it is defined there as a function without a return value, eg &lt;FONT face="courier new,courier"&gt;void myproc();&lt;/FONT&gt;)&lt;/P&gt;
&lt;P&gt;It does not return a value and always needs the &lt;FONT face="courier new,courier"&gt;call&lt;/FONT&gt; keyword.&lt;/P&gt;
&lt;P&gt;Having said that, let's dissect one of the statements from outside in:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx('startmonth',something_complicated_here);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first parameter (or argument) to call symputx is the name of a macro variable to be created. The second parameter is the value that should go into this new macro variable. An optional third parameter would specifiy if the variable is to be created in the local ('l') or global ('g') symbol table.&lt;/P&gt;
&lt;P&gt;Next layer:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put(some_number,best.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since call symputx (and call symput, BTW) want a character value as their second argument, I use the put() function to prevent any automatic conversion (I like to have complete control over what the computer does for me). The additional leading blanks from the best. format are being taken care of by call symputx.&lt;/P&gt;
&lt;P&gt;Next layer:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dhms(input("&amp;amp;start.-01",yymmdd10.),0,0,0)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The dhms() function computes a datetime value from 4 parameters: date, hours, minutes, seconds. The date needs to be a valid SAS date value (number of days calculated from 1960-01-01, back in time to 1582, and forward to 19999, but limited by the four digits for years in most date formats)&lt;/P&gt;
&lt;P&gt;Innermost layer:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input("&amp;amp;start.-01",yymmdd10.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Make a yyyy-mm-dd string from your macro variable, and use the proper informat to convert the string to a SAS date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 09:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444683#M28756</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-12T09:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444687#M28757</link>
      <description>Fantastic, I think I learn a new thing today, really appreciate your time,&lt;BR /&gt;Just one question , when you added 0,0,0 after the format , are these for h, m and seconds.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Tk&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Mar 2018 09:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444687#M28757</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-03-12T09:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444690#M28758</link>
      <description>&lt;P&gt;Quote:&lt;/P&gt;
&lt;P&gt;The dhms() function computes a datetime value from 4 parameters: date, hours, minutes, seconds&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 09:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444690#M28758</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-12T09:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: macro to extract monthly report</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444734#M28762</link>
      <description>&lt;P&gt;It may not be relevant, since you already have a solution.&amp;nbsp; But here is the point I was trying to make.&amp;nbsp; Perhaps this will help&amp;nbsp;you frame questions in the future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's what you started asking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where d_entry &amp;gt;= '2016-11-01 00:00:00.000' and d_entry&amp;nbsp;&amp;lt; &amp;nbsp;'2017-10-01 00:00:00.000'&amp;nbsp;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's what you actually needed (using a different date range, but that's not the point here):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; d_entry &amp;gt;= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"01JUN2017:00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; and d_entry &amp;lt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"01SEP2017:00:00:00.000"dt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to realize that these statements are different, and the solution will vary depending on what you actually need.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 13:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-to-extract-monthly-report/m-p/444734#M28762</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-12T13:24:26Z</dc:date>
    </item>
  </channel>
</rss>

