<?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 usage in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388604#M93201</link>
    <description>I'm not sure I understand what you mean when you say "days".  I would recommend giving an example of the output dataset that you are looking to create based on the input data that you currently have.</description>
    <pubDate>Wed, 16 Aug 2017 20:35:30 GMT</pubDate>
    <dc:creator>dcruik</dc:creator>
    <dc:date>2017-08-16T20:35:30Z</dc:date>
    <item>
      <title>left join usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388596#M93197</link>
      <description>&lt;P&gt;I used the following code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table fault_CNT_only as
	select Unit, fault_code, count(*) as fault_count
	from all_units_results
	group by Unit, fault_code;
quit;


proc sql;
	create table fault_CNT as
	select A.Unit, A.fault_code, count(*) as fault_count,
	B.sw_install_date
	from all_units_results A left join InstallDate B
	on A.Unit=B.vehicle_no
	group by Unit, fault_code
	;
quit;&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;The output of&amp;nbsp;fault_CNT_only looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;8116 20-1803 1&lt;BR /&gt;8118 20-0715 1&lt;BR /&gt;8119 20-1801 2&lt;BR /&gt;8119 20-1802 2&lt;BR /&gt;8119 20-1803 2&lt;BR /&gt;8119 20-1804 3&lt;BR /&gt;8119 20-1806 2&lt;BR /&gt;8133 20-0794 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;while the output of fault_CNT looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;8116 20-1803 1 02JAN2015&lt;BR /&gt;8118 20-0715 1 01JAN2015&lt;BR /&gt;8119 20-1801 2 01JAN2015&lt;BR /&gt;8119 20-1801 2 01JAN2015&lt;BR /&gt;8119 20-1802 2 01JAN2015&lt;BR /&gt;8119 20-1802 2 01JAN2015&lt;BR /&gt;8119 20-1803 2 01JAN2015&lt;BR /&gt;8119 20-1803 2 01JAN2015&lt;BR /&gt;8119 20-1804 3 01JAN2015&lt;BR /&gt;8119 20-1804 3 01JAN2015&lt;BR /&gt;8119 20-1804 3 01JAN2015&lt;BR /&gt;8119 20-1806 2 01JAN2015&lt;BR /&gt;8119 20-1806 2 01JAN2015&lt;BR /&gt;8133 20-0794 1 01JAN2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get the same number of rows for fault_CNT as in fault_CNT_only?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388596#M93197</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-16T20:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: left join usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388597#M93198</link>
      <description>&lt;P&gt;It looks like you'll need to aggregate/remove the date then somehow. How do you want the date information to be shown?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Fixed spelling of word 'date'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388597#M93198</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-16T20:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: left join usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388600#M93199</link>
      <description>&lt;P&gt;You have to remove your sw_install_date variable that you are brining in from the InstallDate dataset to get the same count. &amp;nbsp;If you need the sw_install_date variable, then you should put it in the GROUP BY&amp;nbsp;and before the count() function in your SELECT statement, although it doesn't mean that you will get the same count. &amp;nbsp;If you have a Unit and Fault_Code combination with multiple sw_install_date values, then you will get more records than the original PROC SQL.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388600#M93199</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2017-08-16T20:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: left join usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388602#M93200</link>
      <description>There are probably multiple sw_install_date values. They may differ by minutes or seconds. I'm only interested in a resolution of days. Is there some way to resolve this variable to a resolution of days?</description>
      <pubDate>Wed, 16 Aug 2017 20:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388602#M93200</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-16T20:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: left join usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388604#M93201</link>
      <description>I'm not sure I understand what you mean when you say "days".  I would recommend giving an example of the output dataset that you are looking to create based on the input data that you currently have.</description>
      <pubDate>Wed, 16 Aug 2017 20:35:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388604#M93201</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2017-08-16T20:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: left join usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388611#M93203</link>
      <description>&lt;P&gt;Dear dcruik,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure I explained the problem well enough. thank you for your original comment. I used your idea and it worked correctly. The code I used has a minor change in the select ordering from what you suggested.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table fault_CNT as
	select A.Unit, A.fault_code, count(*) as fault_count,
		B.sw_install_date
	from all_units_results A left join InstallDate B
	on A.Unit=B.vehicle_no
	group by Unit, fault_code, B.sw_install_date
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The final output has no duplicates and the same number of rows as fault_CNT_only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;8116 20-1803 1 02JAN2015&lt;BR /&gt;8118 20-0715 1 01JAN2015&lt;BR /&gt;8119 20-1801 2 01JAN2015&lt;BR /&gt;8119 20-1802 2 01JAN2015&lt;BR /&gt;8119 20-1803 2 01JAN2015&lt;BR /&gt;8119 20-1804 3 01JAN2015&lt;BR /&gt;8119 20-1806 2 01JAN2015&lt;BR /&gt;8133 20-0794 1 01JAN2015&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/left-join-usage/m-p/388611#M93203</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-16T20:47:13Z</dc:date>
    </item>
  </channel>
</rss>

