<?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: minimum of a column grouped by another column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386168#M92458</link>
    <description>&lt;P&gt;You only need a single query:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table InstallDate as
SELECT
	FLT.vehicle_header,
	FLT.vehicle_no,
	FLT.occur_date,
	FLT.FAULT_CODE,
	FLT.FAULT_DESCRIPTION,
	min(FLT.occur_date) as sw_install_date
FROM RMDEOAP.GETS_DW_EOA_FAULTS FLT
WHERE 
	FLT.vehicle_header = 'NS' and
	FLT.occur_date between '25Jul2017:00:00:00'dt and datetime()
group by FLT.vehicle_no;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Aug 2017 02:50:19 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2017-08-08T02:50:19Z</dc:date>
    <item>
      <title>minimum of a column grouped by another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386147#M92453</link>
      <description>&lt;P&gt;The following code produces a 22-322 and a 76-322 syntax error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table InstallDate as
		SELECT
			FLT.vehicle_header,
			FLT.vehicle_no,
			FLT.occur_date,
			FLT.FAULT_CODE,
			FLT.FAULT_DESCRIPTION
		FROM RMDEOAP.GETS_DW_EOA_FAULTS FLT
			WHERE 
			FLT.vehicle_header = 'NS'
			/*and FLT.occur_date between '25Sep2016:00:00:00'dt and datetime()*/
			and FLT.occur_date between '25Jul2017:00:00:00'dt and datetime()
	;
quit;
data InstallDate;
set InstallDate;
select min( occur_date) as sw_install_date
group by vehicle_no
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The error message appears following the statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select min( occur_date) as sw_install_date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to find the minimum occur_date grouped by vehicle number.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and best regards.&lt;/P&gt;&lt;P&gt;capam&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 20:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386147#M92453</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-07T20:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: minimum of a column grouped by another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386151#M92454</link>
      <description>Your first SQL looks fine. But why do you switch to a data step (and mix with SQL syntax - which isn't supported)?</description>
      <pubDate>Mon, 07 Aug 2017 21:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386151#M92454</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-08-07T21:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: minimum of a column grouped by another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386168#M92458</link>
      <description>&lt;P&gt;You only need a single query:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table InstallDate as
SELECT
	FLT.vehicle_header,
	FLT.vehicle_no,
	FLT.occur_date,
	FLT.FAULT_CODE,
	FLT.FAULT_DESCRIPTION,
	min(FLT.occur_date) as sw_install_date
FROM RMDEOAP.GETS_DW_EOA_FAULTS FLT
WHERE 
	FLT.vehicle_header = 'NS' and
	FLT.occur_date between '25Jul2017:00:00:00'dt and datetime()
group by FLT.vehicle_no;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 02:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386168#M92458</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-08T02:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: minimum of a column grouped by another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386207#M92465</link>
      <description>&lt;P&gt;Hi PGStats&lt;/P&gt;&lt;P&gt;I tried your suggestion and got the following error:&lt;/P&gt;&lt;P&gt;17 proc sql;&lt;BR /&gt;18 create table InstallDate as&lt;BR /&gt;19 SELECT&lt;BR /&gt;20 FLT.vehicle_header,&lt;BR /&gt;21 FLT.vehicle_no,&lt;BR /&gt;22 FLT.occur_date,&lt;BR /&gt;23 FLT.FAULT_CODE,&lt;BR /&gt;24 FLT.FAULT_DESCRIPTION&lt;BR /&gt;25 min(FLT.occur_date) as sw_install_date&lt;BR /&gt;26 FROM RMDEOAP.GETS_DW_EOA_FAULTS FLT&lt;BR /&gt;27 WHERE&lt;BR /&gt;28 FLT.vehicle_header = 'NS' and&lt;BR /&gt;29 FLT.occur_date between '25Jul2017:00:00:00'dt and datetime()&lt;BR /&gt;30 group by FLT.vehicle_no&lt;BR /&gt;31 ;&lt;BR /&gt;ERROR: Expression using minimum of (&amp;gt;&amp;lt;) has components that are of different data types.&lt;BR /&gt;WARNING: A GROUP BY clause has been transformed into an ORDER BY clause because neither the SELECT clause nor the optional HAVING&lt;BR /&gt;clause of the associated table-expression referenced a summary function.&lt;BR /&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;BR /&gt;32 quit;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;capam&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 10:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386207#M92465</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-08T10:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: minimum of a column grouped by another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386217#M92466</link>
      <description>Sorry, I forgot a comma after line 24 above. Thanks for the help.</description>
      <pubDate>Tue, 08 Aug 2017 11:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minimum-of-a-column-grouped-by-another-column/m-p/386217#M92466</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-08T11:41:02Z</dc:date>
    </item>
  </channel>
</rss>

