<?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: Create a data set for each month between 2 dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698378#M213580</link>
    <description>&lt;P&gt;In short, I am not using 1 data set because it has been previously set up as multiple data sets with 1000s of lines of code and I believe it will be more efficient to continue as the code currently is than to go back and re-write all of the code.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 13:27:48 GMT</pubDate>
    <dc:creator>GS2</dc:creator>
    <dc:date>2020-11-12T13:27:48Z</dc:date>
    <item>
      <title>Create a data set for each month between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698229#M213513</link>
      <description>&lt;P&gt;Using SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an efficient way to create SAS data sets for each month and year combination between 2 dates. For example 1 data set has dates between Jan 2017 and Dec 2020 and I would like to create a data set for Jan 2017, Feb 2017, Mar 2017 ... Dec 2020. Is there an efficient way to do this without having to individually create the data set? I understand the preference would be to keep all data together in one data set but the code is set up for individual data sets. Any ideas on the best way to go about this would be appreciated. Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 21:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698229#M213513</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-11-11T21:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set for each month between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698291#M213536</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; Is there an efficient way to create SAS data sets for each month and year combination between 2 dates.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp; I understand the preference would be to keep all data together in one data set&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;There we go, you answered your question. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Why can't your code reference the main data set with a where clause rather than reference a data set name?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Instead of loading&amp;nbsp; &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;DATASET_202011&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp; you call&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;MAINDATASET; if put(DATE,yymmn6.)='202011';&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 04:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698291#M213536</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-11-12T04:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set for each month between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698378#M213580</link>
      <description>&lt;P&gt;In short, I am not using 1 data set because it has been previously set up as multiple data sets with 1000s of lines of code and I believe it will be more efficient to continue as the code currently is than to go back and re-write all of the code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 13:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698378#M213580</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-11-12T13:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set for each month between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698381#M213582</link>
      <description>&lt;P&gt;Create monthly data sets containing what? How should these monthly data sets be named? Yes, of course it is possible (although I would not call it "efficient") using macros or possibly CALL EXECUTE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sure that your very long code that works with these monthly data sets could be shortened quite a bit by having it working with a single data set containing all months; but if you don't feel its worth your time to change the programming, I understand.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 13:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698381#M213582</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-12T13:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set for each month between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698398#M213584</link>
      <description>&lt;P&gt;Write the code for one (or possibly two) months.&amp;nbsp; Then figure out how to generate that code for all of the dates.&lt;/P&gt;
&lt;P&gt;Example data step to split out two months of data into individual datasets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want_2017_01 want_2017_02 ;
  set have;
  if '01JAN2017'd &amp;lt;= date &amp;lt; '01FEB2017'd then output want_2017_01;
  else if '01FEB2017'd &amp;lt;= date &amp;lt; '01MAR2017'd then output want_2017_02;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You also might want to create views, especially if your real dataset has an index on DATE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want_2017_01 / view=want_2017_01;
  set have;
  where date between '01JAN2017'd and '31JAN207'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 15:08:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698398#M213584</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-12T15:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set for each month between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698573#M213659</link>
      <description>&lt;P&gt;Something like this might help:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro loop(start=, end=);
  %local i;
  %do i=&amp;amp;start. %to &amp;amp;end.;
    %if %substr(&amp;amp;i.,5,2)=13 %then %let i=%eval(&amp;amp;i+100-12);
    data DS_&amp;amp;i.; T=1; run;
  %end;
%mend;

%loop(start=201901, end=202010);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 04:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-for-each-month-between-2-dates/m-p/698573#M213659</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-11-13T04:18:30Z</dc:date>
    </item>
  </channel>
</rss>

