<?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: Incorrect date format input to intnx function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332643#M272050</link>
    <description>&lt;P&gt;You have a couple of issues with this code.&amp;nbsp; First, where is &amp;amp;CYCLE_END_DT supposed to come from?&amp;nbsp; This code tries to use it, but never creates it.&amp;nbsp; So a portion of the code is missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, what is in it?&amp;nbsp; One of these must be incorrect (or both, I guess):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&amp;amp;cycle_end_dt"d&lt;/P&gt;
&lt;P&gt;"&amp;amp;cycle_end_dt"dt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same line of code refers to both.&amp;nbsp; The top reference assumes that the contents of &amp;amp;CYCLE_END_DT represent a date.&amp;nbsp; The bottom&amp;nbsp;reference assumes that the contents of &amp;amp;CYCLE_END_DT represent a date-time.&amp;nbsp; It's not possible for both to be correct.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2017 15:19:09 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-02-14T15:19:09Z</dc:date>
    <item>
      <title>Incorrect date format input to intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332638#M272048</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;could any one give a hand with the following piece of code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;see attachment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It returns this error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: Apparent symbolic reference CYCLE_END_DT not resolved.&lt;/P&gt;
&lt;P&gt;ERROR: Invalid date/time/datetime constant "&amp;amp;cycle_end_dt"d.&lt;/P&gt;
&lt;P&gt;WARNING: Apparent symbolic reference CYCLE_END_DT not resolved.&lt;/P&gt;
&lt;P&gt;ERROR: Invalid date/time/datetime constant "&amp;amp;cycle_end_dt"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;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Macro m(country,month);

data _null_;
month_end_dt = put(intnx('month',mdy(substr("&amp;amp;cycle",1,length("&amp;amp;cycle")-2),1,substr("&amp;amp;cycle",length("&amp;amp;cycle")-1,2)),-1,'end'),date9.)||':23:59:59.000';
year = year(input(month_end_dt,date9.));
month = substr(compress(0||month(input(month_end_dt,date9.))),length(compress(0||month(input(month_end_dt,date9.))))-1,2);
year_month = cat(year,"_",month);
call symput('month_end_dt',put(input(month_end_dt,datetime22.3),datetime22.3));
call symput('ym',year_month);
run;

DATA	basedata_1_&amp;amp;country._&amp;amp;ym;
SET		DM_CMDM.VW_TRX_LINE (keep= PK_COUNTRY_ID FK_CONSUMER_ID TRX_EVENT_END PK_RETAIL_TRANS_LINE_ITEM_ID FK_PRODUCT_ID SALES_QUANTITY ACTUAL_SALES_PRICE POINTS);
WHERE pk_country_id = "&amp;amp;country"
AND INTNX('DTWEEK',"&amp;amp;cycle_end_dt"d,-13,'S') &amp;lt; TRX_EVENT_END &amp;lt;= "&amp;amp;cycle_end_dt"dt;
RUN;

%mend m;

data _null_;
   array x[1] $2 ('BG'/* 'CZ' 'DE' 'HU' 'PL' 'RU' 'SG' 'SK' 'TH'*/);
   	do j=1 to dim(x);
		do i = 8 to 12;
			country = x[j];
			cycle = compress(i||'16');
			call symput('country',country);
			call symput('cycle',cycle);
			call execute ('%m(&amp;amp;country,&amp;amp;cycle)');
		end;
  	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 15:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332638#M272048</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-02-14T15:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect date format input to intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332642#M272049</link>
      <description>&lt;P&gt;That log snippet is telling you that either that macro variable was never created, or it is not in the scope of the current activities. &amp;nbsp;As for attachments, post code in a code window ({i} above the post area) with accompanying test data - in the form of a datastep. &amp;nbsp;This is so we can help you with further questions.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 15:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332642#M272049</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-14T15:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect date format input to intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332643#M272050</link>
      <description>&lt;P&gt;You have a couple of issues with this code.&amp;nbsp; First, where is &amp;amp;CYCLE_END_DT supposed to come from?&amp;nbsp; This code tries to use it, but never creates it.&amp;nbsp; So a portion of the code is missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, what is in it?&amp;nbsp; One of these must be incorrect (or both, I guess):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&amp;amp;cycle_end_dt"d&lt;/P&gt;
&lt;P&gt;"&amp;amp;cycle_end_dt"dt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same line of code refers to both.&amp;nbsp; The top reference assumes that the contents of &amp;amp;CYCLE_END_DT represent a date.&amp;nbsp; The bottom&amp;nbsp;reference assumes that the contents of &amp;amp;CYCLE_END_DT represent a date-time.&amp;nbsp; It's not possible for both to be correct.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 15:19:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332643#M272050</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-14T15:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect date format input to intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332648#M272051</link>
      <description>&lt;P&gt;Thx for your suggestion. I mistakenly pasted a macro variable cycle&amp;nbsp;into the place where derived local variable should be called. It is working now.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 15:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332648#M272051</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-02-14T15:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect date format input to intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332650#M272052</link>
      <description>&lt;P&gt;First of all, I'd do the call execute differently:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
array x[1] $2 ('BG'/* 'CZ' 'DE' 'HU' 'PL' 'RU' 'SG' 'SK' 'TH'*/);
do j=1 to dim(x);
  do i = 8 to 12;
    country = x[j];
    cycle = compress(i||'16');
    call execute ('%m('!!trim(country)!!','!!trim(cycle)!!')');
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Keep in mind that code that is submitted with call execute will run &lt;U&gt;after&lt;/U&gt; the current data step has finished, and the macro variables will have the last values set, so you get a number of runs with identical parameters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I see absolutely no place in your macro where cycle_end_dt is set, so it's no miracle it can't be resolved.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 15:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332650#M272052</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-14T15:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect date format input to intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332655#M272053</link>
      <description>&lt;P&gt;Copied the code in the original post from the attachment to a code window. It seems I have retained some of my superpowers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 15:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-date-format-input-to-intnx-function/m-p/332655#M272053</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-14T15:26:49Z</dc:date>
    </item>
  </channel>
</rss>

