<?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 join 2020 data to 2021 for date format YYYYMM in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-2020-data-to-2021-for-date-format-YYYYMM/m-p/710067#M218505</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year(t1.date) = year(datepart(t2.date)) + 1 and month(t1,date) = month(t2.date)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This approach checks the years match and then the months&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This approach uses INTNX() and compares the actual dates, making sure to align them all to the start of the month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intnx('month', t1.date, 0, 'b') = intnx('month', datepart(t2.date), -12, 'b')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if the day is present it will be included in the comparison which is why I've used the alignment parameter in the INTNX function to align the date to the beginning of the month.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If neither of these work, please provide some examples of what isn't working for you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/332279"&gt;@adisal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello ,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a scenario where I join the data from pervious month to the current month. The format for the column is YYYYMM (202001). The condition is like below:&lt;/P&gt;
&lt;P&gt;input(YYYMM,6.)+1 = input(put(DATEPART(DATE),yymmn6.),6.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am unable to figure out how to make this condition work for 2021 . I have to fetch data where I join Dec 2020 data to Jan 2021,&lt;/P&gt;
&lt;P&gt;so I want the condition like this 202012 +1 = 202101 but the above condition will not fetch 202101 data but instead give 202012 +1 = 201213.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for helping .&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jan 2021 22:32:07 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-01-07T22:32:07Z</dc:date>
    <item>
      <title>How to join 2020 data to 2021 for date format YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-2020-data-to-2021-for-date-format-YYYYMM/m-p/710062#M218502</link>
      <description>&lt;P&gt;Hello ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a scenario where I join the data from pervious month to the current month. The format for the column is YYYYMM (202001). The condition is like below:&lt;/P&gt;&lt;P&gt;input(YYYMM,6.)+1 = input(put(DATEPART(DATE),yymmn6.),6.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am unable to figure out how to make this condition work for 2021 . I have to fetch data where I join Dec 2020 data to Jan 2021,&lt;/P&gt;&lt;P&gt;so I want the condition like this 202012 +1 = 202101 but the above condition will not fetch 202101 data but instead give 202012 +1 = 201213.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for helping .&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 21:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-join-2020-data-to-2021-for-date-format-YYYYMM/m-p/710062#M218502</guid>
      <dc:creator>adisal</dc:creator>
      <dc:date>2021-01-07T21:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2020 data to 2021 for date format YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-2020-data-to-2021-for-date-format-YYYYMM/m-p/710067#M218505</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year(t1.date) = year(datepart(t2.date)) + 1 and month(t1,date) = month(t2.date)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This approach checks the years match and then the months&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This approach uses INTNX() and compares the actual dates, making sure to align them all to the start of the month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intnx('month', t1.date, 0, 'b') = intnx('month', datepart(t2.date), -12, 'b')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if the day is present it will be included in the comparison which is why I've used the alignment parameter in the INTNX function to align the date to the beginning of the month.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If neither of these work, please provide some examples of what isn't working for you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/332279"&gt;@adisal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello ,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a scenario where I join the data from pervious month to the current month. The format for the column is YYYYMM (202001). The condition is like below:&lt;/P&gt;
&lt;P&gt;input(YYYMM,6.)+1 = input(put(DATEPART(DATE),yymmn6.),6.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am unable to figure out how to make this condition work for 2021 . I have to fetch data where I join Dec 2020 data to Jan 2021,&lt;/P&gt;
&lt;P&gt;so I want the condition like this 202012 +1 = 202101 but the above condition will not fetch 202101 data but instead give 202012 +1 = 201213.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for helping .&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 22:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-join-2020-data-to-2021-for-date-format-YYYYMM/m-p/710067#M218505</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-01-07T22:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2020 data to 2021 for date format YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-2020-data-to-2021-for-date-format-YYYYMM/m-p/710069#M218507</link>
      <description>&lt;P&gt;if dt2020 is a number like 202001 and DATE is a SAS datetime value, the condition for matching consecutive months should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;intnx("month", mdy(mod(dt2020,100),1,int(dt2020/100)), 1) = intnx("month", datepart(date), 0)&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 22:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-join-2020-data-to-2021-for-date-format-YYYYMM/m-p/710069#M218507</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-01-07T22:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2020 data to 2021 for date format YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-2020-data-to-2021-for-date-format-YYYYMM/m-p/710070#M218508</link>
      <description>&lt;P&gt;It really isn't clear what you want.&lt;/P&gt;
&lt;P&gt;To manipulate date values, like add a month, you would use the INTNX function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your starting value is a datetime then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Newvalue = intnx('dtmonth', datetimevariable, 1);&amp;nbsp; would advance a datetime value by one month.&lt;/P&gt;
&lt;P&gt;If you only want a date&lt;/P&gt;
&lt;P&gt;Newvalue = intnx('month', datepart(datetimevariable),1);&lt;/P&gt;
&lt;P&gt;you can add an alignment to the intnx function to be the Beginning, End, or Same (interval int the result)&lt;/P&gt;
&lt;P&gt;Newvalue = intnx('month', datepart(datetimevariable),1,'B'); would force the result to be the first day of the next month.&lt;/P&gt;
&lt;P&gt;Then assign a format if creating a new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There NEVER a need to use input(put(DATEPART(DATE),&amp;lt;format&amp;gt;),&amp;lt;informat&amp;gt;);&lt;/P&gt;
&lt;P&gt;If you want a date just use: Newvar = datepart(date); And assign a format to the result.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 22:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-join-2020-data-to-2021-for-date-format-YYYYMM/m-p/710070#M218508</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-07T22:40:26Z</dc:date>
    </item>
  </channel>
</rss>

