<?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: Prompt Use in SAS Query Advanced Calculation in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Prompt-Use-in-SAS-Query-Advanced-Calculation/m-p/231140#M16786</link>
    <description>&lt;P&gt;Hi Engin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Couple of questions:&lt;/P&gt;&lt;P&gt;1. What does the query do? (besides a 'case when'; what are you trying to accomplish with the results of the query)&lt;/P&gt;&lt;P&gt;2. When does the query run? (does it always run on the last day of the month? Or also on onther days/dates?&lt;/P&gt;&lt;P&gt;3. What is the reason&amp;nbsp;you're using a prompted value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe there are multiple solutions depending on the questions above.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Oct 2015 13:12:22 GMT</pubDate>
    <dc:creator>Matthijs</dc:creator>
    <dc:date>2015-10-22T13:12:22Z</dc:date>
    <item>
      <title>Prompt Use in SAS Query Advanced Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Prompt-Use-in-SAS-Query-Advanced-Calculation/m-p/230687#M16755</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to build a query which is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;case when t1.date between "31AUG2015"d - 365 and "31aug2015"d then 1 else 0 end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but since I have to run this query every month-end. I have to change "31aug2015" to "30sep2015" next month and so ever.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any prompt technique to handle this automatically?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2015 08:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Prompt-Use-in-SAS-Query-Advanced-Calculation/m-p/230687#M16755</guid>
      <dc:creator>engin</dc:creator>
      <dc:date>2015-10-20T08:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Prompt Use in SAS Query Advanced Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Prompt-Use-in-SAS-Query-Advanced-Calculation/m-p/230713#M16756</link>
      <description>&lt;P&gt;Hi mate,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a macro that contains the date, and if you only need to run this process in the end of the month you can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mondate = %sysfunc(date(),date9.);
%put &amp;amp;mondate.;

/*Check the SAS Log to see the result*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you need to execute where you don't know when (everyday) you may do the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%GLOBAL YEARDT
		ANO
		MES
		INTERVALO
		ANOI
		MESI
		BASES;

%LET YEARDT = %SYSFUNC(DATE(),YYMMP10.);
%LET ANO	= %SUBSTR(&amp;amp;YEARDT.,1,4);
%LET MES	= %SUBSTR(&amp;amp;YEARDT.,6,2);
%PUT &amp;amp;ANO&amp;amp;MES.;

%MACRO APPEND(NUM);
DATA NEED;
   SET
%DO I = 0 %TO &amp;amp;NUM;
%LET INTERVALO = %SYSFUNC(PUTN(%SYSFUNC(INTNX(MONTH,%SYSFUNC(DATE()),-&amp;amp;&amp;amp;I.)),YYMMP10.));
%LET ANOI	= %SUBSTR(&amp;amp;INTERVALO.,1,4);
%LET MESI	= %SUBSTR(&amp;amp;INTERVALO.,6,2);
%LET BASES  = BASE_&amp;amp;ANOI&amp;amp;MESI.;
%PUT &amp;amp;BASES.;
	&amp;amp;BASES.
%END;;
RUN;
%MEND; 
%APPEND(3);

/*This code appends the last three months of tables*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you need to use the macro in a date the syntax is like this "&amp;amp;macro."d or&amp;nbsp;&lt;SPAN&gt;"&amp;amp;macro."dt&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the second code you only need to change the number in &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%APPEND(/*Put here the number you want*/);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this will help you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2015 12:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Prompt-Use-in-SAS-Query-Advanced-Calculation/m-p/230713#M16756</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-10-20T12:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Prompt Use in SAS Query Advanced Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Prompt-Use-in-SAS-Query-Advanced-Calculation/m-p/231140#M16786</link>
      <description>&lt;P&gt;Hi Engin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Couple of questions:&lt;/P&gt;&lt;P&gt;1. What does the query do? (besides a 'case when'; what are you trying to accomplish with the results of the query)&lt;/P&gt;&lt;P&gt;2. When does the query run? (does it always run on the last day of the month? Or also on onther days/dates?&lt;/P&gt;&lt;P&gt;3. What is the reason&amp;nbsp;you're using a prompted value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe there are multiple solutions depending on the questions above.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 13:12:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Prompt-Use-in-SAS-Query-Advanced-Calculation/m-p/231140#M16786</guid>
      <dc:creator>Matthijs</dc:creator>
      <dc:date>2015-10-22T13:12:22Z</dc:date>
    </item>
  </channel>
</rss>

