<?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: SELECT DISTINCT ON MULTIPLE COLUMNS, SPECIFY COLUMNS TO BE RETAINED in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161385#M263372</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Depending on how you created the summaries I might be tempted to go back a step or two as it would seem that you went to extra work to get the summaries attached to the VAR1, 2 and 3 list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since apparently the value for VAR6 etc are duplicated then the simplest SQL solution would look something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct var1,var2,var3, var6,var7,var8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Feb 2015 17:53:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-02-10T17:53:04Z</dc:date>
    <item>
      <title>SELECT DISTINCT ON MULTIPLE COLUMNS, SPECIFY COLUMNS TO BE RETAINED</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161381#M263368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a simple question :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a table selecting distinct observations&amp;nbsp; from an existing table based on combination of three columns but I want to retain some more variables from the original table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;something like : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT DISTINCT on (var1, var2, var3) (keep = var1, var2, var3, var6, var7, var8)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORDER by var1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var6, var7 and var8 contain the values I want to keep in my output table. what is the correct format for doing this ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;Nikhil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 17:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161381#M263368</guid>
      <dc:creator>ngnikhilgoyal</dc:creator>
      <dc:date>2015-02-10T17:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT DISTINCT ON MULTIPLE COLUMNS, SPECIFY COLUMNS TO BE RETAINED</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161382#M263369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your looking at a join but if VAR1, 2 and 3 are repeated WHICH values of VAR6, 7 and 8 do you want?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or possibly&lt;/P&gt;&lt;P&gt;proc sort data=have out= want nodupkey, by var1 var2 var3;run;&lt;/P&gt;&lt;P&gt;which will have some value for var6, 7 and 8 but which ones?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 17:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161382#M263369</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-10T17:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT DISTINCT ON MULTIPLE COLUMNS, SPECIFY COLUMNS TO BE RETAINED</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161383#M263370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;They way I have summarized them, the vals in var6, var7 and var8 are all same for distinct combinations of var1, var2 and var3. So I don't care which value it retains . . &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 17:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161383#M263370</guid>
      <dc:creator>ngnikhilgoyal</dc:creator>
      <dc:date>2015-02-10T17:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT DISTINCT ON MULTIPLE COLUMNS, SPECIFY COLUMNS TO BE RETAINED</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161384#M263371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay it was a silly question I think. I've just chosen all the columns i want to keep in the select distinct statement. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 17:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161384#M263371</guid>
      <dc:creator>ngnikhilgoyal</dc:creator>
      <dc:date>2015-02-10T17:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT DISTINCT ON MULTIPLE COLUMNS, SPECIFY COLUMNS TO BE RETAINED</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161385#M263372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Depending on how you created the summaries I might be tempted to go back a step or two as it would seem that you went to extra work to get the summaries attached to the VAR1, 2 and 3 list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since apparently the value for VAR6 etc are duplicated then the simplest SQL solution would look something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct var1,var2,var3, var6,var7,var8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 17:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161385#M263372</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-10T17:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT DISTINCT ON MULTIPLE COLUMNS, SPECIFY COLUMNS TO BE RETAINED</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161386#M263373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes &lt;A __default_attr="260198" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; you are right. I am wasting computing resources doing the same calculations again &amp;amp; again. I'll change the order of sub-setting &amp;amp; calculations. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 17:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SELECT-DISTINCT-ON-MULTIPLE-COLUMNS-SPECIFY-COLUMNS-TO-BE/m-p/161386#M263373</guid>
      <dc:creator>ngnikhilgoyal</dc:creator>
      <dc:date>2015-02-10T17:57:07Z</dc:date>
    </item>
  </channel>
</rss>

