<?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 DO loop with date variable as by-variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-with-date-variable-as-by-variable/m-p/428222#M105702</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem with implementing a DO loop using date variables as by-variable.&lt;/P&gt;&lt;P&gt;I have searched this community and found a way. But there comes an error when I tweak a little.&lt;/P&gt;&lt;P&gt;See the code first. This one works fine.&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;options symbolgen;
%macro daily00(X) /des = "Sample Macro";
	%do i=1 %to 3;
		%put &amp;amp;X._&amp;amp;i;
	%end;
%mend daily00;
%macro iteration00(BeginDate, EndDate) /des = "Sample Macro";
		%do j=%sysfunc(inputn(&amp;amp;begindate,date9.)) %to %sysfunc(inputn(&amp;amp;enddate,date9.));
			%daily00(X=&amp;amp;j);
		%end;
%mend iteration00;
%iteration00(BeginDate=23Dec2014, EndDate=24Dec2014);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now I want to change&amp;nbsp;the BeginDate and EndDate to YYYYMMDD, so in this case it would be 20141223 and 20141224, respectively.&lt;/P&gt;&lt;P&gt;I tried the below but something's wrong. I think I am confused with INPUT or INFORMAT syntax, but I am lost.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen;
%macro daily00(X) /des = "Sample Macro";
	%do i=1 %to 3;
		%put &amp;amp;X._&amp;amp;i;
	%end;
%mend daily00;
%macro iteration00(BeginDate, EndDate) /des = "Sample Macro";
		%do j=%sysfunc(inputn(&amp;amp;begindate,8.)) %to %sysfunc(inputn(&amp;amp;enddate,8.));
			%daily00(X=&amp;amp;j);
		%end;
%mend iteration00;
%iteration00(BeginDate=20141223, EndDate=20141224);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason I am trying to use date&amp;nbsp;format in this DO loop is because, I want to avoid numeric values such as 20141240 when calling datasets in the DAILY00 macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS 9.4.&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jan 2018 23:49:11 GMT</pubDate>
    <dc:creator>MadQuant</dc:creator>
    <dc:date>2018-01-16T23:49:11Z</dc:date>
    <item>
      <title>DO loop with date variable as by-variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-with-date-variable-as-by-variable/m-p/428222#M105702</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem with implementing a DO loop using date variables as by-variable.&lt;/P&gt;&lt;P&gt;I have searched this community and found a way. But there comes an error when I tweak a little.&lt;/P&gt;&lt;P&gt;See the code first. This one works fine.&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;options symbolgen;
%macro daily00(X) /des = "Sample Macro";
	%do i=1 %to 3;
		%put &amp;amp;X._&amp;amp;i;
	%end;
%mend daily00;
%macro iteration00(BeginDate, EndDate) /des = "Sample Macro";
		%do j=%sysfunc(inputn(&amp;amp;begindate,date9.)) %to %sysfunc(inputn(&amp;amp;enddate,date9.));
			%daily00(X=&amp;amp;j);
		%end;
%mend iteration00;
%iteration00(BeginDate=23Dec2014, EndDate=24Dec2014);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now I want to change&amp;nbsp;the BeginDate and EndDate to YYYYMMDD, so in this case it would be 20141223 and 20141224, respectively.&lt;/P&gt;&lt;P&gt;I tried the below but something's wrong. I think I am confused with INPUT or INFORMAT syntax, but I am lost.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen;
%macro daily00(X) /des = "Sample Macro";
	%do i=1 %to 3;
		%put &amp;amp;X._&amp;amp;i;
	%end;
%mend daily00;
%macro iteration00(BeginDate, EndDate) /des = "Sample Macro";
		%do j=%sysfunc(inputn(&amp;amp;begindate,8.)) %to %sysfunc(inputn(&amp;amp;enddate,8.));
			%daily00(X=&amp;amp;j);
		%end;
%mend iteration00;
%iteration00(BeginDate=20141223, EndDate=20141224);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason I am trying to use date&amp;nbsp;format in this DO loop is because, I want to avoid numeric values such as 20141240 when calling datasets in the DAILY00 macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS 9.4.&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 23:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-with-date-variable-as-by-variable/m-p/428222#M105702</guid>
      <dc:creator>MadQuant</dc:creator>
      <dc:date>2018-01-16T23:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop with date variable as by-variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-with-date-variable-as-by-variable/m-p/428225#M105703</link>
      <description>&lt;P&gt;Yes, the informat is incorrect.&amp;nbsp; You are using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But should be using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;yymmdd8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, you define %daily00 using X as a positional parameter.&amp;nbsp; But your macro call uses it as a keyword parameter.&amp;nbsp; Presumably that's just a typo.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 23:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-with-date-variable-as-by-variable/m-p/428225#M105703</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-16T23:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop with date variable as by-variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-loop-with-date-variable-as-by-variable/m-p/428229#M105706</link>
      <description>&lt;P&gt;Thanks you. It works!&lt;/P&gt;&lt;P&gt;I was keep trying&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yymmddn8.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;since the numbers didn't have any usual delimiters such as / or -.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 00:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-loop-with-date-variable-as-by-variable/m-p/428229#M105706</guid>
      <dc:creator>MadQuant</dc:creator>
      <dc:date>2018-01-17T00:15:34Z</dc:date>
    </item>
  </channel>
</rss>

