<?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 do I create a calendar table in proc sql? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782192#M249356</link>
    <description>&lt;P&gt;You can not&amp;nbsp; get it by pure SQL statement in SAS.&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;%macro calendar_table(start_date=  );
%let start=%sysfunc(inputn(&amp;amp;start_date.,date9.)); 
%let end=%sysfunc(intnx(year,%sysfunc(date()),0,e));
%let n_month=%sysfunc(intck(month,&amp;amp;start.,&amp;amp;end.));

proc sql;
create table want(date num format yymmn6.,year num,month num);
insert into want 
%do i=0 %to &amp;amp;n_month.;
 %let date=%sysfunc(intnx(month,&amp;amp;start.,&amp;amp;i.));
 %let year=%sysfunc(year(&amp;amp;date.));
 %let month=%sysfunc(month(&amp;amp;date.));
 values(&amp;amp;date.,&amp;amp;year.,&amp;amp;month.) 
%end;
;
quit;
%mend;


%calendar_table(start_date= 01oct2018 )&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Nov 2021 11:48:12 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-11-24T11:48:12Z</dc:date>
    <item>
      <title>How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782137#M249319</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a beginner at SAS programming.&lt;/P&gt;&lt;P&gt;I have to create a date-master table a.k.a. calendar table in proc SQL.&lt;/P&gt;&lt;P&gt;(Every code should write in proc SQL in SAS.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, the date should be in the format yyyymm.&lt;/P&gt;&lt;P&gt;The start date is fixed like 201810.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The end date should be the last month of the current year like 202112.&lt;/P&gt;&lt;P&gt;(I hope to use the function;today() etc)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output should be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Year&amp;nbsp; &amp;nbsp; &amp;nbsp;Month&amp;nbsp;&lt;/P&gt;&lt;P&gt;201810&amp;nbsp; &amp;nbsp; 2018&amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;201811&amp;nbsp; &amp;nbsp; 2018&amp;nbsp; &amp;nbsp; 11&lt;/P&gt;&lt;P&gt;201812&amp;nbsp; &amp;nbsp; 2019&amp;nbsp; &amp;nbsp; 12&lt;/P&gt;&lt;P&gt;201901&amp;nbsp; &amp;nbsp; 2019&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I could get any help, I will really appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 06:20:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782137#M249319</guid>
      <dc:creator>seohyeonjeong</dc:creator>
      <dc:date>2021-11-24T06:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782140#M249322</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;Every code should write in proc SQL&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;SQL is a really limited and poor language compared to SAS's.&lt;/P&gt;
&lt;P&gt;This limitation means many things will be much harder or near impossible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A five-line SAS code might necessitate hundreds of SQL code lines to do the same job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 06:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782140#M249322</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-24T06:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782145#M249326</link>
      <description>&lt;P&gt;This task could be solved in data step easily, but i don't see a solution using proc sql. Please explain why you want proc sql.&lt;/P&gt;
&lt;P&gt;Here's a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.calendar;
   StartDate = '1Oct2018'd;
   EndDate = mdy(12, 1, year(today()));
   Date = StartDate;

   do while(Date &amp;lt; EndDate);
      Year = year(Date);
      Month = month(Date);
      output;
      Date = intnx('month', date, 1, 'B');
   end;

   format Date yymmn6.;
   drop StartDate EndDate;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Nov 2021 07:26:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782145#M249326</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-11-24T07:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782192#M249356</link>
      <description>&lt;P&gt;You can not&amp;nbsp; get it by pure SQL statement in SAS.&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;%macro calendar_table(start_date=  );
%let start=%sysfunc(inputn(&amp;amp;start_date.,date9.)); 
%let end=%sysfunc(intnx(year,%sysfunc(date()),0,e));
%let n_month=%sysfunc(intck(month,&amp;amp;start.,&amp;amp;end.));

proc sql;
create table want(date num format yymmn6.,year num,month num);
insert into want 
%do i=0 %to &amp;amp;n_month.;
 %let date=%sysfunc(intnx(month,&amp;amp;start.,&amp;amp;i.));
 %let year=%sysfunc(year(&amp;amp;date.));
 %let month=%sysfunc(month(&amp;amp;date.));
 values(&amp;amp;date.,&amp;amp;year.,&amp;amp;month.) 
%end;
;
quit;
%mend;


%calendar_table(start_date= 01oct2018 )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Nov 2021 11:48:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782192#M249356</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-11-24T11:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782393#M249402</link>
      <description>&lt;P&gt;Truly it is.&lt;/P&gt;&lt;P&gt;But thank you for making this code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are going to change almost every SAS code to SQL language in the near future, so I have to change every code by using PROC SQL as possible as I can. Thank you anyway!:)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 05:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782393#M249402</guid>
      <dc:creator>seohyeonjeong</dc:creator>
      <dc:date>2021-11-25T05:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782398#M249407</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/385687"&gt;@seohyeonjeong&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;...&lt;BR /&gt;
&lt;P&gt;We are going to change almost every SAS code to SQL language in the near future, &lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why? To increase memory usage? To make code less readable?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:08:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782398#M249407</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-11-25T07:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782400#M249409</link>
      <description>&lt;P&gt;To multiply the number of lines of code, a sure measure of code quality and coder productivity.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782400#M249409</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-25T07:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782402#M249411</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; You can not&amp;nbsp; get it by pure SQL statement in SAS.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;One cold argue this is pure SQL. The macro language just writes the SQL code instead of the developer.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If only SQL should used, them the macro language is off limits right?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Come on OP, you know you want to write all that endless SQL code. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782402#M249411</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-25T07:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782427#M249424</link>
      <description>Yes.But it mixed with Macro which is not supposed to there.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"Come on OP, you know you want to write all that endless SQL code. "&lt;BR /&gt;Chris, You are too rascal .</description>
      <pubDate>Thu, 25 Nov 2021 12:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782427#M249424</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-11-25T12:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a calendar table in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782601#M249503</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisNZ_1-1637964930893.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66135i00E4B086BE0DE314/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisNZ_1-1637964930893.png" alt="ChrisNZ_1-1637964930893.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Nov 2021 22:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-calendar-table-in-proc-sql/m-p/782601#M249503</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-26T22:15:43Z</dc:date>
    </item>
  </channel>
</rss>

