<?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 Select Distinct from Group in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322774#M9289</link>
    <description>&lt;P&gt;If my dataset has 10 columns, but &amp;nbsp;I only want distinct rows selected based on the values of four of those...can it be done? I want all 10 columns in my out put, but again, select distinct only being evaulated on four of those columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can this be done in an extract node in DI Studio as well?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jan 2017 20:02:06 GMT</pubDate>
    <dc:creator>jwhite</dc:creator>
    <dc:date>2017-01-05T20:02:06Z</dc:date>
    <item>
      <title>Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322774#M9289</link>
      <description>&lt;P&gt;If my dataset has 10 columns, but &amp;nbsp;I only want distinct rows selected based on the values of four of those...can it be done? I want all 10 columns in my out put, but again, select distinct only being evaulated on four of those columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can this be done in an extract node in DI Studio as well?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 20:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322774#M9289</guid>
      <dc:creator>jwhite</dc:creator>
      <dc:date>2017-01-05T20:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322778#M9291</link>
      <description>&lt;P&gt;Yes, but you do need to specify some rules so you're sure on how the other values are selected. Assuming they aren't identical, how do you want them to be selected?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie the first four (order doesn't matter) columns are identical, but the next one isn't. Which row will be selected? What are the rules? That will define your logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A B C D 10&lt;/P&gt;
&lt;P&gt;A B C D 10&lt;/P&gt;
&lt;P&gt;A B C D 30&lt;/P&gt;
&lt;P&gt;A B C D 50&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 20:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322778#M9291</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-05T20:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322815#M9295</link>
      <description>&lt;P&gt;Let's say i want the highest value in the fifth column...where do we go from there?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm attampting to do this in DI Studio, but would like the proper syntax as well for understanding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 21:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322815#M9295</guid>
      <dc:creator>jwhite</dc:creator>
      <dc:date>2017-01-05T21:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322824#M9296</link>
      <description>&lt;P&gt;Is this what you want? I'm often wary of using&amp;nbsp;&lt;EM&gt;distinct&lt;/EM&gt; when using&amp;nbsp;&lt;EM&gt;group by&lt;/EM&gt;, because it can distort the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data source;
infile cards;
attrib col1-col4 length=$ 1;
attrib col5 length=3;
input col1-col5;
cards;
A B C D 10
A B C D 10
A B C D 30
A B C D 50
;
run;

proc sql;
create table result as
   select col1,
          col2,
          col3,
          col4,
          max(col5) as max_col5
     from source
    group by col1,
             col2,
             col3,
             col4;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322824#M9296</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-05T22:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322829#M9297</link>
      <description>&lt;P&gt;I'm not sure if you're using custom SQL or the GUI tools in DI Studio. I suspect the latter, so I'll leave that for someone else to answer since I don't work with DI Studio. For custom SQL,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt;&amp;nbsp;answer is correct, you would use an aggregate function in the SQL to select the fifth and other columns.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322829#M9297</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-05T22:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322831#M9298</link>
      <description>&lt;P&gt;Both the extract and SQL queries in DI will allow you to generate code virtually identical to my hand-cut suggestion; note that extract doesn't allow the&amp;nbsp;&lt;EM&gt;having&lt;/EM&gt;&amp;nbsp;clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have DI here to show what it would look like, but I can talk you through it if you like. It's best for debugging purposes not to use custom SQL code - let the transformation tool do all the heavy lifting if you can get away with it.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322831#M9298</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-05T22:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322834#M9299</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt;&amp;nbsp; I know there is the option to include some custom code in DI Studio transformations. I feel pretty proficient with the basic use of the nodes, so if you've got tips on how to do this via DI Studio Extract node (or other), I'd love to see them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322834#M9299</guid>
      <dc:creator>jwhite</dc:creator>
      <dc:date>2017-01-05T22:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322835#M9300</link>
      <description>&lt;P&gt;I'm going to rudely assume that you've not used too much DI and start from scratch (sorry!). I shall also make mistakes because I'm doing it from memory… (Sorry again)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Plonk your source table in the project and drag over the &lt;EM&gt;SQL Extract&lt;/EM&gt; transformation and join them one to another.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Open up the transformation and map the first four columns to the target. If they're there already (I hate auto-mapping with a passion), remove the&amp;nbsp;&lt;EM&gt;fifth&lt;/EM&gt; column, and any of the other columns that may have been put there autoblackmagically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the fifth column, make its name in the target area something meaningful. In the&amp;nbsp;&lt;EM&gt;expression&lt;/EM&gt; field, enter&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;max(col5)&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the &lt;EM&gt;group by&lt;/EM&gt; tab (again I'm doing this from memory), select the first four columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result will only be in a work dataset, of course, but I'll leave all the rest to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This &lt;EM&gt;should&lt;/EM&gt; work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322835#M9300</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-05T22:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322885#M9305</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/20678"&gt;@jwhite&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;If I don't know how to do something in DIS then I normally start with working out how the code logic should look like. That's the SQL&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt;&amp;nbsp;already provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The functionality of the SQL Extract transformation is a sub-set of the SQL Join transformation. It happened to me more than once that I've used the Extract transformation and then came a change where the required functionality was only available in the SQL Join transformation and I had to re-build everything. For this reason I've stopped using the Extract transformation at all and always use the Join transformation to begin with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you want to do is pretty basic. Here some screenshots.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample job:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6603i7EB0883374629C55/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL Join Node "Aggregate by name and sex":&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6604iDB92AF3DE1EE97FE/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6606iDCCB1F4996330BCB/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6605i12AE822AD74777E2/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 02:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322885#M9305</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-01-06T02:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322903#M9307</link>
      <description>&lt;P&gt;Ah - that's the one. Thank you, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;.&amp;nbsp;I should have checked for that sort of example. And if only I could convince SAS Inst to give me a copy of SAS/DI…&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I concur over the Extract/Join comparison. I use Extract when I&amp;nbsp;&lt;EM&gt;know&lt;/EM&gt; that the transformation will remain a simple one, but I much prefer the power of the join.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 08:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322903#M9307</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-06T08:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322908#M9308</link>
      <description>&lt;P&gt;Let try "Sort" node to order &lt;U&gt;&lt;FONT color="#FF0000"&gt;5 keys&lt;/FONT&gt;&lt;/U&gt;(#5 key is the descending value)&amp;nbsp;which you mention, then use "Data Validation" node to reject duplicate row by &lt;U&gt;&lt;FONT color="#FF0000"&gt;4&amp;nbsp;keys&lt;/FONT&gt;&lt;/U&gt; (select option: Move all but one row to error table).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;hope it can help you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 09:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322908#M9308</guid>
      <dc:creator>Kritsana</dc:creator>
      <dc:date>2017-01-06T09:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322912#M9309</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89317"&gt;@Kritsana&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;What you propose could be done with the Sort node only using NODUPKEY. The disadvantage of this method is that the selected non-key variable values will be "random". &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 08:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322912#M9309</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-01-06T08:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322921#M9310</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&lt;BR /&gt;Thank you very much for your advised. My propose is just provided another way to get result, the reason to use Data Validation node because jwhite want to descending column #5 if there're more duplication values in 4 keys.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 09:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322921#M9310</guid>
      <dc:creator>Kritsana</dc:creator>
      <dc:date>2017-01-06T09:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322973#M9312</link>
      <description>&lt;P&gt;Wow! I used the Join statement, messaged it a bit more to suit my needs, and it worked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you guys expand a little more on using Join instead of Extract (when not actually joining multiple tables)? I hadn't heard of or considered this before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 15:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/322973#M9312</guid>
      <dc:creator>jwhite</dc:creator>
      <dc:date>2017-01-06T15:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323093#M9316</link>
      <description>&lt;P&gt;I had some extra time this afternoon and attempted to do the same thing with an Extract node...and I was.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt;, can you please just elaborate a little more why I should consider using joins more fequently!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and have a great weekend!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 21:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323093#M9316</guid>
      <dc:creator>jwhite</dc:creator>
      <dc:date>2017-01-06T21:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323109#M9317</link>
      <description>&lt;P&gt;The main difference when you've only got one source dataset is that the &lt;EM&gt;Extract&lt;/EM&gt; transformation doesn't support&amp;nbsp;&lt;EM&gt;having&lt;/EM&gt;. But the extra flexibility (ease of changing procedure and dataset options, for example) make it more superior again. I still use&amp;nbsp;&lt;EM&gt;Extract&lt;/EM&gt;, but only when I know that the requirements for using it are simple and will (in all likelihood) not change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally, when I'm writing SAS by hand I tend towards using a data step, because of the control and often sheer speed it gives me.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When joining two or more tables together,&amp;nbsp;I chop and change between an SQL join and a dataset merge/update. It depends on the structure (especially width) and overall size of the datasets. I do have a generic DI transformation that I've written that does a dataset merge - it requires that the two source datasets are sorted. Even with massively denormalised tables on both sides, it screams through - something that SQL has trouble doing.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 22:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323109#M9317</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-06T22:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323386#M9323</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt;, how would this logic work of the rows have different values in the grouped columns?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;A B C D 10
A B C D 10
A B C D 30
A B C D 50&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&amp;nbsp;&lt;BR /&gt;A B H D 10&lt;BR /&gt;A B H D 10&lt;BR /&gt;A B H D 10&lt;BR /&gt;A B H D 20&lt;BR /&gt;F F F D 10&lt;BR /&gt;F F F D 30&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;With the above and doing a max() on the fifth column...the value in the 5th column for all rows will be 50, which is the highest. Seemingly even when I group the first four. I get:&lt;/P&gt;
&lt;P&gt;A B C D 50&lt;/P&gt;
&lt;P&gt;A B H D 50&lt;/P&gt;
&lt;P&gt;F F F D 50&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I desire would be:&lt;/P&gt;
&lt;P&gt;A B C D 50&lt;/P&gt;
&lt;P&gt;A B H D 20&lt;/P&gt;
&lt;P&gt;F F F D 30&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess I would think that the max() would evaluate for the highest value within the group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that not correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 15:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323386#M9323</guid>
      <dc:creator>jwhite</dc:creator>
      <dc:date>2017-01-09T15:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323429#M9324</link>
      <description>Nevermind. I think I've got it.&lt;BR /&gt;&lt;BR /&gt;I appreciate all the help and insight!</description>
      <pubDate>Mon, 09 Jan 2017 18:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323429#M9324</guid>
      <dc:creator>jwhite</dc:creator>
      <dc:date>2017-01-09T18:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323466#M9325</link>
      <description>&lt;P&gt;If the other columns are numeric and amenable to statistic such as max or min (and few others) as an alternate approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=have nway;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class col1 col2 col3 col4 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var var1 var2 var3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=want(drop = _type_ _freq_) max= ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 21:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/323466#M9325</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-09T21:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Select Distinct from Group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/325316#M9417</link>
      <description>I think that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt; nailed it with "I use Extract when I know that the transformation will remain a simple one".&lt;BR /&gt;Extract is easier to use and understand, so as long as Join is not simplified I think it has its place.&lt;BR /&gt;If you have only 1-1 mappings it's not that much of penalty to switch to join if you later find out that the Extract isn't enough.</description>
      <pubDate>Tue, 17 Jan 2017 16:15:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Select-Distinct-from-Group/m-p/325316#M9417</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-01-17T16:15:53Z</dc:date>
    </item>
  </channel>
</rss>

