<?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: nodupkey and SQL in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302677#M20528</link>
    <description>&lt;P&gt;If you want to see the same number of records as produced by sort nodupkey, try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SELECT DISTINCT wclientcode, szaccountnumber, raisedmth &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;FROM master_query;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to see the same number of records as your query, try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc sort data=master_query nodupkey; by _all_; run;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2016 14:45:36 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-10-05T14:45:36Z</dc:date>
    <item>
      <title>nodupkey and SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302585#M20519</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to convert below statatement of SAS in SQL&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=strat.master_query nodupkey out=strat.master_query_unq; by wclientcode szaccountnumber raisedmth; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it like DISTINCT in SQL ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT * FROM&amp;nbsp;&lt;SPAN&gt;master_query SORT BY&amp;nbsp;wclientcode szaccountnumber raisedmth&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But it is not giving correct reocrds with SQL statement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can someone please help me ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks In advance&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 11:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302585#M20519</guid>
      <dc:creator>yudhishtirb</dc:creator>
      <dc:date>2016-10-05T11:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: nodupkey and SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302597#M20520</link>
      <description>&lt;P&gt;If you do sort with nodupkey, only one record per by values is kept; if additional variables in the dataset have different values between rows, only one of those values is therefore kept, the others are discarded.&lt;/P&gt;
&lt;P&gt;Select distinct, OTOH, looks at all variables in the select list (which happen to be all variables in the dataset when using *), and keeps multiple records per "order by" group if there are non-unique values in the other columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IMO, if a SQL distinct creates something different than a sort nodupkey, this is a sign for sloppy programming, as values may be lost with the sort.&lt;/P&gt;
&lt;P&gt;Look if all columns from your input dataset are needed; a proper keep in the sort step (that shows what columns are significant and makes for better understanding of the code) and a proper select with only the needed columns might be the right thing to do.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 12:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302597#M20520</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-05T12:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: nodupkey and SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302626#M20523</link>
      <description>&lt;P&gt;No, they are not the same.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;by wclientcode szaccountnumber raisedmth;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This orders the SAS data by the variables given in the by statement, then by _n_ if there are more than one. &amp;nbsp;Nodupkey will take the first record per that by grouping to output.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Distinct will select a distinct value based on the sort order defined internally, which will consider all variables as * means all variables. &amp;nbsp;Note that in SQL the syntax is:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;order by &amp;lt;variable&amp;gt;{, &amp;lt;variable};&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The question is, why do you need to change SAS code which you have working for SQL code which you don't know?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 13:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302626#M20523</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-05T13:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: nodupkey and SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302677#M20528</link>
      <description>&lt;P&gt;If you want to see the same number of records as produced by sort nodupkey, try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SELECT DISTINCT wclientcode, szaccountnumber, raisedmth &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;FROM master_query;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to see the same number of records as your query, try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc sort data=master_query nodupkey; by _all_; run;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 14:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302677#M20528</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-10-05T14:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: nodupkey and SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302709#M20534</link>
      <description>If you got working code, why change it?&lt;BR /&gt;If you are doing a migration from SAS then you are better off asking this question in forum appropriate for your target environment.</description>
      <pubDate>Wed, 05 Oct 2016 15:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/nodupkey-and-SQL/m-p/302709#M20534</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-10-05T15:51:29Z</dc:date>
    </item>
  </channel>
</rss>

