<?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 Deleting duplications in Proc SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14318#M2252</link>
    <description>I want to Delete all Duplicate records in Proc SQL step.&lt;BR /&gt;
we have &lt;BR /&gt;
Proc sort data = a nodupkey;&lt;BR /&gt;
By cust;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I need the same result in Proc SQL step.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Alankar</description>
    <pubDate>Thu, 02 Apr 2009 02:58:31 GMT</pubDate>
    <dc:creator>Alankar</dc:creator>
    <dc:date>2009-04-02T02:58:31Z</dc:date>
    <item>
      <title>Deleting duplications in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14318#M2252</link>
      <description>I want to Delete all Duplicate records in Proc SQL step.&lt;BR /&gt;
we have &lt;BR /&gt;
Proc sort data = a nodupkey;&lt;BR /&gt;
By cust;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I need the same result in Proc SQL step.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Alankar</description>
      <pubDate>Thu, 02 Apr 2009 02:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14318#M2252</guid>
      <dc:creator>Alankar</dc:creator>
      <dc:date>2009-04-02T02:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting duplications in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14319#M2253</link>
      <description>I don't think that there is a direct equivalent to NODUPKEY in SQL.&lt;BR /&gt;
The closest you'll get (at least with some basic SQL coding) is to use DISTINCT.&lt;BR /&gt;
But that will work more like NODUPRECS in SORT.&lt;BR /&gt;
&lt;BR /&gt;
Why do you want to use SQL if SORT works...?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Thu, 02 Apr 2009 06:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14319#M2253</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-04-02T06:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting duplications in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14320#M2254</link>
      <description>I'm trying to compare SAS &amp;amp; SQL.&lt;BR /&gt;
then i got this doubt.&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot.</description>
      <pubDate>Thu, 02 Apr 2009 06:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14320#M2254</guid>
      <dc:creator>Alankar</dc:creator>
      <dc:date>2009-04-02T06:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting duplications in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14321#M2255</link>
      <description>Linus is correct, I also think there's no direct way to mimic the NODUPKEYS feature of PROC SORT in SQL.&lt;BR /&gt;
&lt;BR /&gt;
One way could be:&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
create table NODUPKEYS (drop = _N) as&lt;BR /&gt;
select T1.* from &lt;BR /&gt;
(select monotonic() as _N, * from A) as T1,&lt;BR /&gt;
(select monotonic() as _N, count(CUST) from A group by CUST) as T2&lt;BR /&gt;
where T1._N = T2._N ;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
The monotonic() function here, is used similarly as the automatic variable _N_ (try to run the two selects for T1 and T2 separately to see the results of monotonic()).&lt;BR /&gt;
&lt;BR /&gt;
But it always involves remerging the data with some stat table (in the example T2).&lt;BR /&gt;
So I guess it will be always much more "messy", complex and inefficient than the SORT NODUPKEYS options.&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;

Message was edited by: Daniel Santos</description>
      <pubDate>Thu, 02 Apr 2009 07:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14321#M2255</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-04-02T07:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting duplications in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14322#M2256</link>
      <description>Data XyZ ;&lt;BR /&gt;
Input ID $ tot cost;&lt;BR /&gt;
cards;&lt;BR /&gt;
ABC 10 100&lt;BR /&gt;
XYZ 20 200&lt;BR /&gt;
ABC 10 100&lt;BR /&gt;
;&lt;BR /&gt;
RUN;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   title 'Unique Recods in XYZ Dataset';&lt;BR /&gt;
   create table noduprec as&lt;BR /&gt;
   select *, count(*) as Count&lt;BR /&gt;
      from xyz&lt;BR /&gt;
      group by ID&lt;BR /&gt;
      having count(*) = 1;&lt;BR /&gt;
     &lt;BR /&gt;
 &lt;BR /&gt;
proc print data=noduprec;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 05 May 2009 22:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14322#M2256</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-05T22:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting duplications in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14323#M2257</link>
      <description>There is an extensive discussion of the things that are easier in the DATA step vs SQL in the archives of comp.soft-sys.sas .  You can search them in Google Groups.</description>
      <pubDate>Wed, 06 May 2009 03:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14323#M2257</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2009-05-06T03:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting duplications in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14324#M2258</link>
      <description>Hi Alankar,&lt;BR /&gt;
&lt;BR /&gt;
Here are some methods&lt;BR /&gt;
Look for these&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Method [1]&lt;BR /&gt;
&lt;BR /&gt;
Proc sort data = a nodupkey out=one;&lt;BR /&gt;
By cust;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Method [2]&lt;BR /&gt;
&lt;BR /&gt;
Create table table_name as&lt;BR /&gt;
Select distinct * from table;&lt;BR /&gt;
Quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
sassupport&lt;BR /&gt;
&lt;A href="http://www.reportinghouse.com" target="_blank"&gt;http://www.reportinghouse.com&lt;/A&gt;</description>
      <pubDate>Fri, 08 May 2009 13:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Deleting-duplications-in-Proc-SQL/m-p/14324#M2258</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-08T13:23:40Z</dc:date>
    </item>
  </channel>
</rss>

