<?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: How to create a dataset with a series of dates with a proc sql? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/684236#M207320</link>
    <description>&lt;P&gt;Yes, you can use any table that has more rows than you need dates.&amp;nbsp; The table is unimportant, it is just a way to get to the monotonic functions that number of times.&amp;nbsp; That said, I tested this in EG and SASHELP.TIMEDATA exists there in my installation.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Sep 2020 14:28:05 GMT</pubDate>
    <dc:creator>CurtisMackWSIPP</dc:creator>
    <dc:date>2020-09-16T14:28:05Z</dc:date>
    <item>
      <title>How to create a dataset with a series of dates with a proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/681529#M206147</link>
      <description>&lt;P&gt;Essentially is there a way to recreate this data step with a proc sql?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_date=01Jan2011;
%let end_date=31Dec2017;

/*create table with all available months*/
data _01_dates;
	date_var="&amp;amp;start_date"d;
	do while (date_var&amp;lt;="&amp;amp;end_date"d);
		output;
		date_var=intnx('month', date_var, 1, 's');
	end;
	format date_var date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Sep 2020 22:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/681529#M206147</guid>
      <dc:creator>Ani7</dc:creator>
      <dc:date>2020-09-03T22:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset with a series of dates with a proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/681532#M206148</link>
      <description>&lt;P&gt;Probably. Likely to be a bunch of ugly code. SQL has no concept of loops or iteration per se so you likely have to get into some very ugly and lengthy code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That can be simplified to&lt;/P&gt;
&lt;PRE&gt;data _01_dates;
   do date_var = "&amp;amp;start_date."d to "&amp;amp;end_date."d;
      output;
   end;
   format date_var date9.;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Sep 2020 22:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/681532#M206148</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-03T22:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset with a series of dates with a proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/681535#M206150</link>
      <description>&lt;P&gt;You could do it with macros of course, but you can also do it with the help of any dataset with enough rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let start_date=%sysfunc(mdy(1,1,2011));&lt;BR /&gt;%let end_date=%sysfunc(mdy(12,31,2017));&lt;BR /&gt;proc sql;&lt;BR /&gt;create table junk as&lt;BR /&gt;select monotonic() as n1, intnx('month', &amp;amp;start_date, monotonic() -1, 's') as datevar format date10.&lt;BR /&gt;from sashelp.Timedata&lt;BR /&gt;where calculated datevar &amp;lt; &amp;amp;end_date;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 23:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/681535#M206150</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-03T23:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset with a series of dates with a proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/682940#M206767</link>
      <description>&lt;P&gt;I'm on SAS EG and SASHELP.TIMEDATA doesn't exist for me. Is there no way to do this without using an inbuilt dataset?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 13:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/682940#M206767</guid>
      <dc:creator>Ani7</dc:creator>
      <dc:date>2020-09-10T13:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset with a series of dates with a proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/684236#M207320</link>
      <description>&lt;P&gt;Yes, you can use any table that has more rows than you need dates.&amp;nbsp; The table is unimportant, it is just a way to get to the monotonic functions that number of times.&amp;nbsp; That said, I tested this in EG and SASHELP.TIMEDATA exists there in my installation.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 14:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/684236#M207320</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-16T14:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset with a series of dates with a proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/684240#M207323</link>
      <description>&lt;P&gt;Maxim 14. Stay with your data step.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 14:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/684240#M207323</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-16T14:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset with a series of dates with a proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/684244#M207325</link>
      <description>&lt;P&gt;You could also do it this way if you are in a macro;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro monthsql;
  %let start_date=%sysfunc(mdy(1,1,2011));
  %let end_date=%sysfunc(mdy(12,31,2017));
  proc sql;
  create table junk (datevar date);
  insert into junk (datevar)
    %let thisdate=&amp;amp;start_date;
    %do %until(&amp;amp;thisdate &amp;gt;= &amp;amp;end_date);
      values(&amp;amp;thisdate)
      %let thisdate = %sysfunc(intnx(month, &amp;amp;thisdate, 1, s));
    %end;;
  quit;
%mend;
%monthsql;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Sep 2020 14:41:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dataset-with-a-series-of-dates-with-a-proc-sql/m-p/684244#M207325</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-16T14:41:37Z</dc:date>
    </item>
  </channel>
</rss>

