<?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 an interval of month and year for creating a historic database based on input in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840315#M332271</link>
    <description>&lt;P&gt;In my original code, -18 in the do loop produces the first month, the one you want to number as 1. You can add this to the loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month_number = i+19;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 24 Oct 2022 15:34:51 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-10-24T15:34:51Z</dc:date>
    <item>
      <title>How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/839945#M332098</link>
      <description>&lt;P&gt;Greetings, I am new to SAS, and sorry if this question has already been answered but I have not found exactly what I want.&lt;/P&gt;&lt;P&gt;I have different databases with the format 20xxxx_Name (where the first digits are the year followed by the month, for example 202101, 202208, etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to join the databases in an interval of 12 months depending on a month's input. That is, if I want to analyze 202208, I have to join the tables from 202102-202202. In general, given an input month m, join tables from (m-18) to (m-7).&lt;/P&gt;&lt;P&gt;I don't know if I can use modular arithmetic or use SAS date functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea would be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%LET INPUT_MONTH == m;

DATA WORK.TABLES;
SET WORK.(m-18)_NAME-(m-7)_NAME;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or I don't know if using a for loop is the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your time and help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 14:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/839945#M332098</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2022-10-21T14:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/839958#M332104</link>
      <description>&lt;P&gt;Here's a short macro to do this. Please note you cannot have a data set named work.202102_name because data set names cannot begin with a number, so I have modified the names to be legal and begin with a character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dothis(month=);
data list_of_months;
    input_month=input("&amp;amp;month",yymmn6.);
    do i=-18 to -7;
        this_month=intnx('month',input_month,i,'b');
        output;
    end;
    drop i;
run;
/* Create macro variable containing the data set names */
proc sql noprint;
    select cats('work.month_',put(this_month,yymmn6.)) into :list_of_months separated by ' ' from list_of_Months;
quit;
%put &amp;amp;=list_of_Months; /* this line is optional, it lets you view the macro variable to see which months have been selected */


data work.tables;
    set &amp;amp;list_of_months;
Run;
%mend;

%dothis(month=202208) &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Oct 2022 16:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/839958#M332104</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-21T16:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/839997#M332130</link>
      <description>&lt;P&gt;How about starting with the names of your SAS data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SET statement likes SAS data sets and typically data set names do not start with digits.&lt;/P&gt;
&lt;P&gt;Or is your question really about how to connect to your data base where those things are stored?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will find that for SAS purposes it is more typical to have stuff like your YYYYMM value at the end of a name as then you can use a number of name list forms such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set Name_2000: ;&lt;/P&gt;
&lt;P&gt;which would use all of the data sets whose name starts with Name_2000.&lt;/P&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;P&gt;Set Name_200004 - Name_200010;&lt;/P&gt;
&lt;P&gt;which would attempt to use all of Name_200004, 200005, 200006 ... 200010.&lt;/P&gt;
&lt;P&gt;You could not however use: Name_200011 - Name_200103 as the month numbers 13, 14, ... 99, (and 200100) would likely not exist and the - requires sequential numbering. The set would also have to be in the same Library and the library would need to be part of each element used: Foo.Name_200004 - Foo.Name_200010 for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 18:02:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/839997#M332130</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-21T18:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840101#M332180</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436491"&gt;@sebastiaam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"&lt;EM&gt;I have different databases...&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I assume these are just SAS Tables/SAS Files?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"&lt;EM&gt;...with the format 20xxxx_Name&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you please provide a real example of such a name so we know what we're dealing with? &lt;BR /&gt;SAS table names starting with a number don't comply with the SAS naming standards. Also that it's possible to use such names, it adds some complications and requires some special syntax for dealing with SAS Name Literals.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"&lt;EM&gt;I have to join the databases in an interval of 12 months depending on a month's input.&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I assume it's not JOIN but CONCATENATE? You just want all the rows from 12 monthly tables in a single table - right?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The way such problems are often solved:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;Query SAS metadata (dictionary.tables) via Proc SQL and work out which dated table names are within the desired date range&lt;/SPAN&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;In a SQL Where clause extract the date portion from the table name (column "memname" in dictiorary.tables)&lt;/SPAN&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;Convert the extracted date string into a SAS Date value using the input function with the appropriate informat for the date string.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Test if the extracted SAS date value is within the desired date range&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Populate a SAS macro variable with all the selected table names (select catx('.',libname,memname) into :table_list separarted by ' ' )&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Use the macro variable in a SAS datastep&lt;/SPAN&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;data want; set &amp;amp;table_list; run;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Oct 2022 17:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840101#M332180</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-22T17:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840293#M332260</link>
      <description>Thanks for your help and advice regarding naming!</description>
      <pubDate>Mon, 24 Oct 2022 14:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840293#M332260</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2022-10-24T14:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840294#M332261</link>
      <description>Thanks for your help and suggestions!</description>
      <pubDate>Mon, 24 Oct 2022 14:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840294#M332261</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2022-10-24T14:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840295#M332262</link>
      <description>Thank you so much! This works perfectly!</description>
      <pubDate>Mon, 24 Oct 2022 14:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840295#M332262</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2022-10-24T14:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840300#M332263</link>
      <description>&lt;P&gt;Just a question, why do we use format yymmn6. and not yyyymm?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, the macro is selecting the correct months, for AGO22 it selects FEB21-JAN22, but in the print I got these numbers&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastiaam_1-1666623344871.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76498i6CA868FA8CB44527/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastiaam_1-1666623344871.png" alt="sebastiaam_1-1666623344871.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks again for your time and help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 14:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840300#M332263</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2022-10-24T14:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840303#M332265</link>
      <description>&lt;P&gt;There is no SAS format named YYYYMM&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the data set named &lt;FONT face="courier new,courier"&gt;list_of_months&lt;/FONT&gt; is not used for displaying anything, it doesn't matter how the dates appear.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 15:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840303#M332265</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-24T15:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840304#M332266</link>
      <description>&lt;P&gt;There is no SAS format named YYYYMM, unless you build your own.&amp;nbsp; The SAS format named YYMM display year and month only for a data.&amp;nbsp; The YYMMN does the same but without any delimiter.&amp;nbsp; If you tell it to display using 6 bytes then you get strings like 202203 with match the pattern (not FORMAT) of YYYYMM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Those look like SAS date values.&amp;nbsp; Attach a format to the variables to display them in a more human friendly way.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 15:01:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840304#M332266</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-24T15:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840311#M332269</link>
      <description>&lt;P&gt;Oh!, Ok ok, thanks, I understand.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just another quick question, is there an easy way to make the macro enumerate months? I mean, I have this table&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastiaam_0-1666625077065.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76499i4A915FDECE82C7EB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastiaam_0-1666625077065.png" alt="sebastiaam_0-1666625077065.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;where MREF goes from 202102 to 202202 as desired, I want to enumerate 202102 -&amp;gt; 1, 202103 -&amp;gt;2, ..., 202202 -&amp;gt; 12. When doing this manually I use SELECT 1 as Month, and so on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 15:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840311#M332269</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2022-10-24T15:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840314#M332270</link>
      <description>&lt;P&gt;You could just not DROP the variable I.&lt;/P&gt;
&lt;P&gt;But you might want to make a new variable is the range of values of I is not the range of value you want.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 15:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840314#M332270</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-24T15:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840315#M332271</link>
      <description>&lt;P&gt;In my original code, -18 in the do loop produces the first month, the one you want to number as 1. You can add this to the loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month_number = i+19;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Oct 2022 15:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840315#M332271</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-24T15:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840326#M332276</link>
      <description>&lt;P&gt;Yes, I understand that, but I want to add that column when joining my tables.&lt;/P&gt;&lt;P&gt;Something like&lt;/P&gt;&lt;P&gt;data work.tables;&lt;BR /&gt;set &amp;amp;list_of_months;&lt;BR /&gt;month_number = 1 to 12;&lt;BR /&gt;Run;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 16:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840326#M332276</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2022-10-24T16:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840327#M332277</link>
      <description>&lt;P&gt;Is the actual month a variable in the data sets, or just in the data set name?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 16:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840327#M332277</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-24T16:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840331#M332278</link>
      <description>&lt;P&gt;A variable called MREF&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastiaam_0-1666631041491.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76501iF44299B6B35DB549/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastiaam_0-1666631041491.png" alt="sebastiaam_0-1666631041491.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried to use&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.tables;
    set &amp;amp;list_of_months;
	MES = _N_;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but I got this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sebastiaam_1-1666631094995.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76502i3EB7E0775D6518CD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sebastiaam_1-1666631094995.png" alt="sebastiaam_1-1666631094995.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to obtain somethig like&lt;/P&gt;&lt;P&gt;MREF&amp;nbsp; &amp;nbsp; &amp;nbsp;MES&lt;/P&gt;&lt;P&gt;202102&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;202102&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;202103&amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;202103&amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;202202&amp;nbsp; &amp;nbsp; 12&lt;/P&gt;&lt;P&gt;In other words, adding a label to each table that I am concatenating&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 17:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840331#M332278</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2022-10-24T17:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840332#M332279</link>
      <description>&lt;P&gt;So MREF is an integer that has a value of 202102 for the first record; or is this a formatted value of a numeric variable? What format does MREF have according to PROC CONTENTS?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 17:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840332#M332279</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-24T17:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840333#M332280</link>
      <description>&lt;P&gt;Is an integer, numeric type. But that variable is going to change when merging the tables from list_of_months depending on input, my question I think is simpler.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose we are joining two datasets&lt;/P&gt;&lt;P&gt;data work.tables;&lt;BR /&gt;set table1 - table2;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;Suppose table1 and table 2 have attributes x,y,z&lt;/P&gt;&lt;P&gt;table 1&lt;/P&gt;&lt;P&gt;x y z&lt;/P&gt;&lt;P&gt;2 3 4&lt;/P&gt;&lt;P&gt;5 6 7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;table 2&lt;/P&gt;&lt;P&gt;x y z&lt;/P&gt;&lt;P&gt;2 6 7&lt;/P&gt;&lt;P&gt;9 8 2&lt;/P&gt;&lt;P&gt;I want dataset tables to have a tag from which table the row is, meaning&lt;/P&gt;&lt;P&gt;tables:&lt;/P&gt;&lt;P&gt;x y z label&lt;/P&gt;&lt;P&gt;2 3 4 1&lt;/P&gt;&lt;P&gt;5 6 7 1&lt;/P&gt;&lt;P&gt;2 6 7 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;9 8 2 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 17:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840333#M332280</guid>
      <dc:creator>sebastiaam</dc:creator>
      <dc:date>2022-10-24T17:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840335#M332281</link>
      <description>&lt;P&gt;You did not provide an answer to the question I asked:&amp;nbsp;&lt;SPAN&gt;What format does MREF have according to PROC CONTENTS?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your latest examples where months are no longer part of the discussion are not useful here.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 17:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840335#M332281</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-24T17:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Create an interval of month and year for creating a historic database based on input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840340#M332283</link>
      <description>&lt;P&gt;You can add a dataset option to set a variable TRUE or FALSE to indicate if that dataset contributed to the observation.&lt;/P&gt;
&lt;P&gt;(Note that variable is not written to the output so you will need to copy the information).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set table1(in=in1) table2(in=in2);
  if in1 then label=1;
  else if in2 then label=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also use the INDSNAME= option of the SET statement.&amp;nbsp; &amp;nbsp;That variable is also not kept.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set table1 table2 indsname=dsn;
  label=dsn;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In this case you have to do less work, but LABEL is now a character variable and not a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if TABLE1 and TABLE2 already have a variable that indicates the month that was coded into their name then you don't need to do either of these.&amp;nbsp; You already know which dataset contributed the observation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
  input x y z;
  label=1;
cards;
2 3 4
5 6 7
;

data table2 ;
  input x y z;
  label=2;
cards;
2 6 7
9 8 2
;

data want;
 set table1 table2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Yet another reason not to encoding data into the name of an object (dataset name in this case).&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 18:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Create-an-interval-of-month-and-year-for-creating-a/m-p/840340#M332283</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-24T18:04:29Z</dc:date>
    </item>
  </channel>
</rss>

