<?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: How to select all columns but filter out on certain columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/402988#M278879</link>
    <description>&lt;P&gt;If table_1 is sorted by A B C then this may do what you want:&lt;/P&gt;
&lt;PRE&gt;data table_2;
   set table_1;
   by a b c;
   if first.c;
run;&lt;/PRE&gt;
&lt;P&gt;If there is some actual criteria involved for choice of D and E&amp;nbsp; you need to show it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 23:20:42 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-10-10T23:20:42Z</dc:date>
    <item>
      <title>How to select all columns but filter out on certain columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/402959#M278876</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have table_1 with columns (A, B, C, D, E).&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the rows within table_1, I would like to select rows of data where A, B, C are unique, but I also plan to keep information for D &amp;amp; E.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will this one work?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc Sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Create Table table_2 as select * from table_1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; left join&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (select distinct A, B, C from table_1) m&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;on table_1. A = m.A and table_1.B = m.B and table_1.C = m.C;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 21:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/402959#M278876</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-10-10T21:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all columns but filter out on certain columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/402963#M278877</link>
      <description>&lt;P&gt;You really should provide some example input data and the desired result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Unique combination" tends to imply a single result but when you say "plan to keep information for D &amp;amp; E." which values do you want?&lt;/P&gt;
&lt;P&gt;if the example data looked like&lt;/P&gt;
&lt;P&gt;&lt;U&gt;A&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;U&gt;B&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;U&gt;C&amp;nbsp;&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;U&gt;D&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;U&gt;E&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Avalue Bvalue Cvalue somethingforD somethingforE&lt;/P&gt;
&lt;P&gt;Avalue Bvalue Cvalue otherDvalue&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherEvalue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which values from D and E would you want?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 21:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/402963#M278877</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-10T21:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all columns but filter out on certain columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/402971#M278878</link>
      <description>&lt;P&gt;Thanks for reminding.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table_1:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; C&amp;nbsp; &amp;nbsp;D&amp;nbsp; &amp;nbsp;E&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; 7&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In table_2:&amp;nbsp; &amp;nbsp; we only have first two rows. Since the third row has same (A, B, C) value with the second one.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 22:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/402971#M278878</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-10-10T22:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all columns but filter out on certain columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/402988#M278879</link>
      <description>&lt;P&gt;If table_1 is sorted by A B C then this may do what you want:&lt;/P&gt;
&lt;PRE&gt;data table_2;
   set table_1;
   by a b c;
   if first.c;
run;&lt;/PRE&gt;
&lt;P&gt;If there is some actual criteria involved for choice of D and E&amp;nbsp; you need to show it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 23:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/402988#M278879</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-10T23:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all columns but filter out on certain columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403015#M278880</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I may not provide a good example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table_1, example as below:&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; C&amp;nbsp; &amp;nbsp;D&amp;nbsp; &amp;nbsp;E&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; 7&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; 8&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table_2, we will have the following:&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; C&amp;nbsp; &amp;nbsp;D&amp;nbsp; &amp;nbsp;E&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; 7&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; 8&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Because the last&amp;nbsp;row in table_1 is same as the third one because they have same information on (A, B and C)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I was wondering in your code,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;will this part 'first.c' filter on 'A, B and C' information?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 04:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403015#M278880</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-10-11T04:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all columns but filter out on certain columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403017#M278881</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50019"&gt;@Crubal&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Why don't you use your sample data and run it with the code&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;provided?&lt;/P&gt;
&lt;P&gt;In doing so: Is the result what you want? And if not how should the desired result using your sample data look like?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 05:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403017#M278881</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-11T05:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all columns but filter out on certain columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403200#M278882</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50019"&gt;@Crubal&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry I may not provide a good example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table_1, example as below:&lt;/P&gt;
&lt;P&gt;A&amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; C&amp;nbsp; &amp;nbsp;D&amp;nbsp; &amp;nbsp;E&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; 7&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; 8&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; 2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table_2, we will have the following:&lt;/P&gt;
&lt;P&gt;A&amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; C&amp;nbsp; &amp;nbsp;D&amp;nbsp; &amp;nbsp;E&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; 7&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; 8&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Because the last&amp;nbsp;row in table_1 is same as the third one because they have same information on (A, B and C)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I was wondering in your code,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;will this part 'first.c' filter on 'A, B and C' information?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the &lt;STRONG&gt;data is sorted&lt;/STRONG&gt; by the variables A, B and C and you use a BY A B C statement in a data step when each record is processed the SAS adds automatic values that are true&amp;nbsp;for the First and Last for each variable in combination&amp;nbsp;on the By statement. Using "if first.C" checks if the current record has the first of a group of values for the variable C within the current combination of values of A and B and only keeps records where first.C is true.&lt;/P&gt;
&lt;P&gt;Try sorting your data and running the example code and check to see if the result is as needed. If you don't like the resulting values of D and E you'll have to explain why not with a rule.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 15:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403200#M278882</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-11T15:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all columns but filter out on certain columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403207#M278883</link>
      <description>&lt;P&gt;If you sort the data by ABC, but tell proc sort to segregate the unique keys, you will solve this problem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=_null_ nouniquekey  uniout=want;
  by a b c;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Oct 2017 15:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403207#M278883</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-11T15:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all columns but filter out on certain columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403252#M278884</link>
      <description>&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 16:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-columns-but-filter-out-on-certain-columns/m-p/403252#M278884</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-10-11T16:48:17Z</dc:date>
    </item>
  </channel>
</rss>

