<?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: Proc sql joins: the number of rows doesn't add up! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852861#M337104</link>
    <description>Hi Paige,&lt;BR /&gt;Thank you for you message! I put a distinct option after the select and the number are nearer to what I wanted: when left joining A to B, C is 2130000 and when inner joining C with A, I obtain a number of rows that is just a bit more than A.&lt;BR /&gt;I gave for granted the proc sql joins and considered basic skills, but maybe I didn't understand very much!!</description>
    <pubDate>Mon, 09 Jan 2023 16:58:30 GMT</pubDate>
    <dc:creator>Haemoglobin17</dc:creator>
    <dc:date>2023-01-09T16:58:30Z</dc:date>
    <item>
      <title>Proc sql joins: the number of rows doesn't add up!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852854#M337099</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;
&lt;P&gt;I have a dataset (A) of approximately 2120000, I wanted to left join a couple of variables from a dataset B with a simple proc sql, when I realized that the number of rows in the resulting dataset (C) was 2140000.&lt;/P&gt;
&lt;P&gt;I just wanted to add the two columns to the first rows keeping all the records from the first column. Is there a way?&lt;/P&gt;
&lt;P&gt;I also tried a inner join between the first dataset 2120000 (A) rows and the table that I produced (2140000 rows) (C) and I obtained a dataset with 4 million of records! It is so strange! With a inner join the number of rows should drop, isn't it?&lt;/P&gt;
&lt;P&gt;Is there any way I can solve this issue?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 16:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852854#M337099</guid>
      <dc:creator>Haemoglobin17</dc:creator>
      <dc:date>2023-01-09T16:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joins: the number of rows doesn't add up!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852856#M337101</link>
      <description>&lt;P&gt;A possible explanation is that dataset B has multiple records for some values of the joined variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that is the case, then using &lt;FONT face="courier new,courier"&gt;select distinct&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier"&gt;select&lt;/FONT&gt; might fix the problem. Or it might not fix the problem if those multiple records in data set B have different values.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 16:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852856#M337101</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-09T16:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joins: the number of rows doesn't add up!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852857#M337102</link>
      <description>&lt;P&gt;You have duplicates on your key joining variables in one or both data sets. You likely need to modify your join criteria somehow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table 1&lt;/P&gt;
&lt;TABLE border="1" width="44.44444444444445%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;ID&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Year&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;ABC&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;ABC&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;DEF&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2002&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table 2&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%" height="30px"&gt;ID&lt;/TD&gt;
&lt;TD width="50%" height="30px"&gt;Year&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="30px"&gt;ABC&lt;/TD&gt;
&lt;TD width="50%" height="30px"&gt;2001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="30px"&gt;DEF&lt;/TD&gt;
&lt;TD width="50%" height="30px"&gt;2002&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;DEF&lt;/TD&gt;
&lt;TD&gt;2002&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Join (left or inner)&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;ID&lt;/TD&gt;
&lt;TD width="50%"&gt;YEAR&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;ABC&lt;/TD&gt;
&lt;TD width="50%"&gt;2001 (table 1)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;ABC&amp;nbsp;&lt;/TD&gt;
&lt;TD width="50%"&gt;2001 (table 1)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;DEF&lt;/TD&gt;
&lt;TD width="50%"&gt;2002 (table 2)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;DEF&lt;/TD&gt;
&lt;TD&gt;2002 (table 2)&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&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/265569"&gt;@Haemoglobin17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone!&lt;/P&gt;
&lt;P&gt;I have a dataset (A) of approximately 2120000, I wanted to left join a couple of variables from a dataset B with a simple proc sql, when I realized that the number of rows in the resulting dataset (C) was 2140000.&lt;/P&gt;
&lt;P&gt;I just wanted to add the two columns to the first rows keeping all the records from the first column. Is there a way?&lt;/P&gt;
&lt;P&gt;I also tried a inner join between the first dataset 2120000 (A) rows and the table that I produced (2140000 rows) (C) and I obtained a dataset with 4 million of records! It is so strange! With a inner join the number of rows should drop, isn't it?&lt;/P&gt;
&lt;P&gt;Is there any way I can solve this issue?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 16:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852857#M337102</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-01-09T16:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joins: the number of rows doesn't add up!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852861#M337104</link>
      <description>Hi Paige,&lt;BR /&gt;Thank you for you message! I put a distinct option after the select and the number are nearer to what I wanted: when left joining A to B, C is 2130000 and when inner joining C with A, I obtain a number of rows that is just a bit more than A.&lt;BR /&gt;I gave for granted the proc sql joins and considered basic skills, but maybe I didn't understand very much!!</description>
      <pubDate>Mon, 09 Jan 2023 16:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852861#M337104</guid>
      <dc:creator>Haemoglobin17</dc:creator>
      <dc:date>2023-01-09T16:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joins: the number of rows doesn't add up!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852870#M337109</link>
      <description>Hi Reeza!&lt;BR /&gt;Thank you for your message!&lt;BR /&gt;I added a second key in the joining and a distinct  in the select.&lt;BR /&gt;Now I loose only 42 cases. It's a big improvement, but I still a bit troubled for these numbers that doesn't match &lt;span class="lia-unicode-emoji" title=":face_with_open_mouth:"&gt;😮&lt;/span&gt;</description>
      <pubDate>Mon, 09 Jan 2023 17:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852870#M337109</guid>
      <dc:creator>Haemoglobin17</dc:creator>
      <dc:date>2023-01-09T17:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joins: the number of rows doesn't add up!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852871#M337110</link>
      <description>&lt;P&gt;The reason the numbers don't match is that your data doesn't allow them to match. Data set B has replicates that interfere with what you are trying to do (which may not be possible). If you examine data set B, you will see these replicates. Or you could run PROC FREQ on the joining variables.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 17:30:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852871#M337110</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-09T17:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql joins: the number of rows doesn't add up!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852886#M337118</link>
      <description>Find the ones that don't match and look at each record to identify the difference manually then update your code to account for it.</description>
      <pubDate>Mon, 09 Jan 2023 18:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-joins-the-number-of-rows-doesn-t-add-up/m-p/852886#M337118</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-01-09T18:15:01Z</dc:date>
    </item>
  </channel>
</rss>

