<?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: Running same report with different dates in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Running-same-report-with-different-dates/m-p/4913#M1582</link>
    <description>Hi:&lt;BR /&gt;
  This previous post may be useful to you. &lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=6674ᨒ" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=6674ᨒ&lt;/A&gt;&lt;BR /&gt;
It uses SAS Macro variables. So you could build a "generic" WHERE clause from the current date, something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
%let thisdate = %sysfunc(today()); &lt;BR /&gt;
%let thisbeg = %sysfunc(intnx(month,&amp;amp;thisdate,0,beginning));&lt;BR /&gt;
%let thisend = %sysfunc(intnx(month,&amp;amp;thisdate,0,end));&lt;BR /&gt;
%let fmtbeg = %sysfunc(putn(&amp;amp;thisbeg,date9.));&lt;BR /&gt;
%let fmtend = %sysfunc(putn(&amp;amp;thisend,date9.));&lt;BR /&gt;
%let wherecls = where mydatevar between &amp;amp;thisbeg and &amp;amp;thisend;&lt;BR /&gt;
%let where2 = where mydatevar between "&amp;amp;fmtbeg"d and "&amp;amp;fmtend"d;&lt;BR /&gt;
    &lt;BR /&gt;
%put ***************************;&lt;BR /&gt;
   &lt;BR /&gt;
%put thisdate= &amp;amp;thisdate;&lt;BR /&gt;
%put thisbeg= &amp;amp;thisbeg;&lt;BR /&gt;
%put thisend= &amp;amp;thisend;&lt;BR /&gt;
%put fmtbeg = &amp;amp;fmtbeg;&lt;BR /&gt;
%put fmtend = &amp;amp;fmtend;&lt;BR /&gt;
%put where with dates as numbers: &amp;amp;wherecls;&lt;BR /&gt;
%put alternate where with dates as char string: &amp;amp;where2;&lt;BR /&gt;
%put ***************************;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Which generates this output in the LOG and the %PUTs are just showing you how the values of the macro variables are being set. (White space was added here  for ease of reading).&lt;BR /&gt;
[pre]&lt;BR /&gt;
243  %put ***************************;&lt;BR /&gt;
***************************&lt;BR /&gt;
  &lt;BR /&gt;
244&lt;BR /&gt;
245  %put thisdate= &amp;amp;thisdate;&lt;BR /&gt;
thisdate= 17442&lt;BR /&gt;
  &lt;BR /&gt;
246  %put thisbeg= &amp;amp;thisbeg;&lt;BR /&gt;
thisbeg= 17440&lt;BR /&gt;
  &lt;BR /&gt;
247  %put thisend= &amp;amp;thisend;&lt;BR /&gt;
thisend= 17470&lt;BR /&gt;
  &lt;BR /&gt;
248  %put fmtbeg = &amp;amp;fmtbeg;&lt;BR /&gt;
fmtbeg = 01OCT2007&lt;BR /&gt;
  &lt;BR /&gt;
249  %put fmtend = &amp;amp;fmtend;&lt;BR /&gt;
fmtend = 31OCT2007&lt;BR /&gt;
  &lt;BR /&gt;
250  %put where with dates as numbers: &amp;amp;wherecls;&lt;BR /&gt;
where with dates as numbers: where mydatevar between 17440 and 17470&lt;BR /&gt;
  &lt;BR /&gt;
251  %put alternate where with dates as char string: &amp;amp;where2;&lt;BR /&gt;
alternate where with dates as char string: where mydatevar between "01OCT2007"d and "31OCT2007"d&lt;BR /&gt;
   &lt;BR /&gt;
252  %put ***************************;&lt;BR /&gt;
***************************&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
and those 2 where clauses are:&lt;BR /&gt;
[pre]&lt;BR /&gt;
where mydatevar between 17440 and 17470  &lt;BR /&gt;
OR&lt;BR /&gt;
where mydatevar between "01OCT2007"d and "31OCT2007"d&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
So, if MYDATEVAR is a SAS date value, then the  first WHERE clause is comparing the date to the internal "number" for Oct 1 and Oct 31, where the second WHERE clause is using a Date Constant so you can have a readable date in the WHERE clause.&lt;BR /&gt;
&lt;BR /&gt;
You may need to contact Tech Support for help figuring out how to modify the code in your project to use the macro variables in the right place. And for help with %SYSFUNC or the INTNX function.&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
    <pubDate>Wed, 03 Oct 2007 19:15:36 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2007-10-03T19:15:36Z</dc:date>
    <item>
      <title>Running same report with different dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Running-same-report-with-different-dates/m-p/4912#M1581</link>
      <description>I am trying to figure out how to run a query based on term dates and effective dates for members.  I have to qualify by term date &amp;gt; first day of that month and effective date less than  the last day of the month. The results will be for that month.  I was wondering if there was another way I could run this without doing 12 process flow for the whole year.  Also I need to append the data into 1 table.  Any hints on how to accomplish this.</description>
      <pubDate>Wed, 03 Oct 2007 14:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Running-same-report-with-different-dates/m-p/4912#M1581</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-10-03T14:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Running same report with different dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Running-same-report-with-different-dates/m-p/4913#M1582</link>
      <description>Hi:&lt;BR /&gt;
  This previous post may be useful to you. &lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=6674ᨒ" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=6674ᨒ&lt;/A&gt;&lt;BR /&gt;
It uses SAS Macro variables. So you could build a "generic" WHERE clause from the current date, something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
%let thisdate = %sysfunc(today()); &lt;BR /&gt;
%let thisbeg = %sysfunc(intnx(month,&amp;amp;thisdate,0,beginning));&lt;BR /&gt;
%let thisend = %sysfunc(intnx(month,&amp;amp;thisdate,0,end));&lt;BR /&gt;
%let fmtbeg = %sysfunc(putn(&amp;amp;thisbeg,date9.));&lt;BR /&gt;
%let fmtend = %sysfunc(putn(&amp;amp;thisend,date9.));&lt;BR /&gt;
%let wherecls = where mydatevar between &amp;amp;thisbeg and &amp;amp;thisend;&lt;BR /&gt;
%let where2 = where mydatevar between "&amp;amp;fmtbeg"d and "&amp;amp;fmtend"d;&lt;BR /&gt;
    &lt;BR /&gt;
%put ***************************;&lt;BR /&gt;
   &lt;BR /&gt;
%put thisdate= &amp;amp;thisdate;&lt;BR /&gt;
%put thisbeg= &amp;amp;thisbeg;&lt;BR /&gt;
%put thisend= &amp;amp;thisend;&lt;BR /&gt;
%put fmtbeg = &amp;amp;fmtbeg;&lt;BR /&gt;
%put fmtend = &amp;amp;fmtend;&lt;BR /&gt;
%put where with dates as numbers: &amp;amp;wherecls;&lt;BR /&gt;
%put alternate where with dates as char string: &amp;amp;where2;&lt;BR /&gt;
%put ***************************;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Which generates this output in the LOG and the %PUTs are just showing you how the values of the macro variables are being set. (White space was added here  for ease of reading).&lt;BR /&gt;
[pre]&lt;BR /&gt;
243  %put ***************************;&lt;BR /&gt;
***************************&lt;BR /&gt;
  &lt;BR /&gt;
244&lt;BR /&gt;
245  %put thisdate= &amp;amp;thisdate;&lt;BR /&gt;
thisdate= 17442&lt;BR /&gt;
  &lt;BR /&gt;
246  %put thisbeg= &amp;amp;thisbeg;&lt;BR /&gt;
thisbeg= 17440&lt;BR /&gt;
  &lt;BR /&gt;
247  %put thisend= &amp;amp;thisend;&lt;BR /&gt;
thisend= 17470&lt;BR /&gt;
  &lt;BR /&gt;
248  %put fmtbeg = &amp;amp;fmtbeg;&lt;BR /&gt;
fmtbeg = 01OCT2007&lt;BR /&gt;
  &lt;BR /&gt;
249  %put fmtend = &amp;amp;fmtend;&lt;BR /&gt;
fmtend = 31OCT2007&lt;BR /&gt;
  &lt;BR /&gt;
250  %put where with dates as numbers: &amp;amp;wherecls;&lt;BR /&gt;
where with dates as numbers: where mydatevar between 17440 and 17470&lt;BR /&gt;
  &lt;BR /&gt;
251  %put alternate where with dates as char string: &amp;amp;where2;&lt;BR /&gt;
alternate where with dates as char string: where mydatevar between "01OCT2007"d and "31OCT2007"d&lt;BR /&gt;
   &lt;BR /&gt;
252  %put ***************************;&lt;BR /&gt;
***************************&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
and those 2 where clauses are:&lt;BR /&gt;
[pre]&lt;BR /&gt;
where mydatevar between 17440 and 17470  &lt;BR /&gt;
OR&lt;BR /&gt;
where mydatevar between "01OCT2007"d and "31OCT2007"d&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
So, if MYDATEVAR is a SAS date value, then the  first WHERE clause is comparing the date to the internal "number" for Oct 1 and Oct 31, where the second WHERE clause is using a Date Constant so you can have a readable date in the WHERE clause.&lt;BR /&gt;
&lt;BR /&gt;
You may need to contact Tech Support for help figuring out how to modify the code in your project to use the macro variables in the right place. And for help with %SYSFUNC or the INTNX function.&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 03 Oct 2007 19:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Running-same-report-with-different-dates/m-p/4913#M1582</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-10-03T19:15:36Z</dc:date>
    </item>
  </channel>
</rss>

