<?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: Matching dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576653#M163256</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266226"&gt;@jeremy4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would that mean that in relation to my example, it would be:&lt;/P&gt;
&lt;P&gt;on intnx('month',a.cohort_mth,0,'b') = intnx('month',b.mth_end,0,'b')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This one!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Would something like this also work to answer my question?&lt;/P&gt;
&lt;P&gt;on input(put(a.cohort_mth,yymmn6.),6.) = input(put(b.mth_end,yymmn6.),6.)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I stated, formatting does not really help here, it is just extra work to format the result and then unformat it. Also, unless I am missing something here, this does not convert all the dates to Feb 1 2017 which would be needed to do the matching.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2019 15:37:46 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-07-25T15:37:46Z</dc:date>
    <item>
      <title>Matching dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576639#M163248</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a proc sql table and would like to join these two variables by date can someone please help me with the line of code to join them together based on the relevant month (the screenshots are only an extract of the year, so I would like to match &lt;FONT color="#FF0000"&gt;cohort_mth&lt;/FONT&gt;, where any day of the month would be recognised as just the month e.g. 01DEC2017 or 20DEC2017 would both be recognised as DEC2017, so that it matches with the &lt;FONT color="#FF0000"&gt;mth_end&lt;/FONT&gt; variable, which is in the mmmyyyy format)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would mean that any date and month e.g. 01FEB2017 and 15FEB2017 from &lt;FONT color="#FF0000"&gt;cohort_mth&lt;/FONT&gt; would both be recognised as FEB2017 and this would be matched with &lt;FONT color="#FF0000"&gt;FEB2017&lt;/FONT&gt; from mth_end.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have already matched by ID with the line (on a.customer_ID = b.ID and &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;a.cohort_mth=b.mth_end&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;) - can someone please edit the red text so that they are matched together, either by recognising that it is DEC2017 or numerically 201712)? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Dataset A&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cohort month.JPG" style="width: 550px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31305i8A40F51159A2FEC6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Cohort month.JPG" alt="Cohort month.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset B&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Month end.PNG" style="width: 554px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31306iEF48925983D09F32/image-size/large?v=v2&amp;amp;px=999" role="button" title="Month end.PNG" alt="Month end.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 15:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576639#M163248</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-07-25T15:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Matching dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576641#M163249</link>
      <description>&lt;P&gt;You can't do the matching using human readable dates. SAS matches dates by SAS date values, which are integers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to match 01FEB2017 and 15FEB2017, you have to turn them both into the SAS date value integer equivalent of Feb 1, 2017.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use INTNX function to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a SAS data set, you could use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;converted_date=intnx('month',date,0,'b');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The 'b' at the end selects the first day of the month in the variable DATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In PROC SQL, you could use something like this to do the matching&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;on intnx('month',a.date,0,'b') eq intnx('month',b.date,0,'b')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 15:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576641#M163249</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-25T15:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Matching dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576646#M163252</link>
      <description>&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would that mean that in relation to my example, it would be:&lt;/P&gt;&lt;P&gt;on intnx('month',a.cohort_mth,0,'b') = intnx('month',b.mth_end,0,'b')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would something like this also work to answer my question?&lt;/P&gt;&lt;P&gt;on input(put(a.cohort_mth,yymmn6.),6.) = input(put(b.mth_end,yymmn6.),6.)&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 15:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576646#M163252</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-07-25T15:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Matching dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576647#M163253</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266226"&gt;@jeremy4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would that mean that in relation to my example, it would be:&lt;/P&gt;
&lt;P&gt;on intnx('month',a.cohort_mth,0,'b') = intnx('month',b.mth_end,0,'b')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would something like this also work to answer my question?&lt;/P&gt;
&lt;P&gt;on input(put(a.cohort_mth,yymmn6.),6.) = input(put(b.mth_end,yymmn6.),6.)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes.&amp;nbsp; But there is no need for the extra INPUT() function. You can just compare the strings generated by the PUT() functions.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 15:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576647#M163253</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-25T15:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Matching dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576652#M163255</link>
      <description>Thanks, can I confirm that the line of code would be:&lt;BR /&gt;on put(a.cohort_mth,yymmn6.),6.) = put(b.mth_end,yymmn6.),6.) and a.customer_ID = b.ID</description>
      <pubDate>Thu, 25 Jul 2019 15:28:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576652#M163255</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-07-25T15:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Matching dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576653#M163256</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266226"&gt;@jeremy4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would that mean that in relation to my example, it would be:&lt;/P&gt;
&lt;P&gt;on intnx('month',a.cohort_mth,0,'b') = intnx('month',b.mth_end,0,'b')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This one!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Would something like this also work to answer my question?&lt;/P&gt;
&lt;P&gt;on input(put(a.cohort_mth,yymmn6.),6.) = input(put(b.mth_end,yymmn6.),6.)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I stated, formatting does not really help here, it is just extra work to format the result and then unformat it. Also, unless I am missing something here, this does not convert all the dates to Feb 1 2017 which would be needed to do the matching.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 15:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576653#M163256</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-25T15:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Matching dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576654#M163257</link>
      <description>&lt;P&gt;You didn't completer remove the INPUT() function call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;on put(a.cohort_mth,yymmn6.) = put(b.mth_end,yymmn6.)
 and a.customer_ID = b.ID&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 15:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-dates/m-p/576654#M163257</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-25T15:33:07Z</dc:date>
    </item>
  </channel>
</rss>

