<?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: Loop a valid calendar date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-valid-calendar-date/m-p/434473#M107820</link>
    <description>&lt;P&gt;Since SAS date values are counts of days, this can easily be achieved in a do loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let year=2019;

data want;
do mydate = mdy(1,1,&amp;amp;year) to mdy(12,31,&amp;amp;year);
  /* your code */
end;
format mydate yymmddn8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Feb 2018 07:19:59 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-02-06T07:19:59Z</dc:date>
    <item>
      <title>Loop a valid calendar date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-valid-calendar-date/m-p/434472#M107819</link>
      <description>&lt;P&gt;Hi Guys, I want to create a loop, to get the value of date in the entire pre-defined year. For example, if i pre-define 2018, in the output, i want to get 20180101 until 20181231. So if i pre-define 2019, i will get the output result set of 20190101 until 20191231&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then later I will use the result sets to further process my other data. May i know if there is a function to achieve the task?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 07:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-a-valid-calendar-date/m-p/434472#M107819</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-02-06T07:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Loop a valid calendar date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-valid-calendar-date/m-p/434473#M107820</link>
      <description>&lt;P&gt;Since SAS date values are counts of days, this can easily be achieved in a do loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let year=2019;

data want;
do mydate = mdy(1,1,&amp;amp;year) to mdy(12,31,&amp;amp;year);
  /* your code */
end;
format mydate yymmddn8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Feb 2018 07:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-a-valid-calendar-date/m-p/434473#M107820</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-06T07:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Loop a valid calendar date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-valid-calendar-date/m-p/434539#M107836</link>
      <description>&lt;P&gt;hi , you can do it using a do loop also , please refer the below code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dat;&lt;BR /&gt;_date=mdy(1,1,&amp;amp;year);&lt;BR /&gt;output;&lt;BR /&gt;do until (_date=mdy(12,31,&amp;amp;year));&lt;BR /&gt;_date+1;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;format _date date9.;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 14:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-a-valid-calendar-date/m-p/434539#M107836</guid>
      <dc:creator>soham_sas</dc:creator>
      <dc:date>2018-02-06T14:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Loop a valid calendar date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-valid-calendar-date/m-p/434544#M107840</link>
      <description>&lt;P&gt;Not sure how you want to use it, but the year function may be all that you need. e.g.:&lt;/P&gt;
&lt;PRE&gt;data have;
  input date date9.;
  format date date9.;
  cards;
10jan2017
5mar2018
10jun2018
14may2019
;

data want;
  set have (where=(year(date) eq 2018));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 14:44:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-a-valid-calendar-date/m-p/434544#M107840</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-02-06T14:44:26Z</dc:date>
    </item>
  </channel>
</rss>

