<?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: LEFT JOIN - RETURN FIRST MATCHING ROW in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419213#M103054</link>
    <description>&lt;P&gt;That does exactly the same as the left join on the full table.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Dec 2017 15:52:14 GMT</pubDate>
    <dc:creator>fgillen1</dc:creator>
    <dc:date>2017-12-07T15:52:14Z</dc:date>
    <item>
      <title>LEFT JOIN - RETURN FIRST MATCHING ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419196#M103041</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looking to pull geo data to a table via a left join. I have got to a point where I just want to join first matching result in my geo table to my original table. In oracle I would have used something like rownum &amp;lt; 2, is there an equivalent within SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an example of the join and conditions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LEFT JOIN&lt;BR /&gt;TMP_PRPN.COMPANIES_NACE_CODE_GEODIR2 t2&lt;BR /&gt;ON t1.join_status = 0&lt;BR /&gt;AND t1.geo_directory_grp = 'BUILDING'&lt;BR /&gt;AND t2.building_id = t1.geo_directory_id&lt;/P&gt;&lt;P&gt;AND t1.thorfare_id IS NOT MISSING&lt;BR /&gt;AND t2.thorfare_id = t1.thorfare_id&lt;BR /&gt;AND t2.nace_code LIKE ('Q.86.%')&lt;BR /&gt;AND prxchange('s/\b(DOCTOR)\b/ /o',-1,t2.organisation_name) =* cats(t1.firstname, t1.surname)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Finbar&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 15:04:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419196#M103041</guid>
      <dc:creator>fgillen1</dc:creator>
      <dc:date>2017-12-07T15:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN - RETURN FIRST MATCHING ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419199#M103044</link>
      <description>&lt;P&gt;If there is nothing in the data which indicates the record is the "first record" then why not just select distinct () on the values you want to use so you only get one record per group.&amp;nbsp; You can force it to take this adhoc "first record", however its not straight-forward, and not really a good way to be selecting data (as each time you run it, depending on sort orders, indexes, new/deleted data etc.) you may get a different result.&amp;nbsp; Better to isolate the data you really want logically that way each time you run it it will always work the same.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 15:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419199#M103044</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-07T15:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN - RETURN FIRST MATCHING ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419208#M103050</link>
      <description>Building_ID is restricts to an individual building, so as I say for this analysis it will be perfectly fine. Could you send an example piece of code of how you would use it? I have populated fields within PL/SLQ using SELECT DISTINCT() but not in SAS.</description>
      <pubDate>Thu, 07 Dec 2017 15:34:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419208#M103050</guid>
      <dc:creator>fgillen1</dc:creator>
      <dc:date>2017-12-07T15:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN - RETURN FIRST MATCHING ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419209#M103051</link>
      <description>&lt;P&gt;I assume it would be (very) similar.&lt;/P&gt;
&lt;P&gt;Just search the PROC SQL documentation for DISTINCT.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 15:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419209#M103051</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-12-07T15:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN - RETURN FIRST MATCHING ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419210#M103052</link>
      <description>&lt;P&gt;At a guess, the simplest method would be to add a sub-qeury:&lt;/P&gt;
&lt;PRE&gt;LEFT JOIN
(select distinct BUILDING from TMP_PRPN.COMPANIES_NACE_CODE_GEODIR2) t2
ON t1.join_status = 0
AND t1.geo_directory_grp = 'BUILDING'
AND t2.building_id = t1.geo_directory_id&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Dec 2017 15:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419210#M103052</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-07T15:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN - RETURN FIRST MATCHING ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419213#M103054</link>
      <description>&lt;P&gt;That does exactly the same as the left join on the full table.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 15:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419213#M103054</guid>
      <dc:creator>fgillen1</dc:creator>
      <dc:date>2017-12-07T15:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN - RETURN FIRST MATCHING ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419502#M103161</link>
      <description>&lt;P&gt;You will note the word&amp;nbsp;&lt;STRONG&gt;guess&lt;/STRONG&gt; on the first line of the post here.&amp;nbsp; You have not provided anything for me to work with.&amp;nbsp; If you want a good answer provide some&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;test data in the form of a datastep, post it in the code window (its the {I} above post area), and show what you want out.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;/U&gt;You asked "&lt;SPAN&gt;SELECT DISTINCT() but not in SAS." - I showed how this works, I cannot guess your data or process or what you want.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 09:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419502#M103161</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-08T09:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: LEFT JOIN - RETURN FIRST MATCHING ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419506#M103162</link>
      <description>&lt;P&gt;I have created a work around where I have created a unique ID field in the left hand column. Done my left join where it has created extra rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After this I just done a Group By based on the unique id and selected the max address_reference field from the right hand table. Complete!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 09:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LEFT-JOIN-RETURN-FIRST-MATCHING-ROW/m-p/419506#M103162</guid>
      <dc:creator>fgillen1</dc:creator>
      <dc:date>2017-12-08T09:19:36Z</dc:date>
    </item>
  </channel>
</rss>

