<?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 Remove duplicates in proc print in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-duplicates-in-proc-print/m-p/876541#M346291</link>
    <description>&lt;P&gt;In the following code, I want to remove the duplicates. If I want to add proc sort or proc sql to remove duplicates then how to tweak this code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let target_table=&amp;amp;datasource;
%global prompt;

proc print data="&amp;amp;envPath/data/gb/&amp;amp;datasource" noobs;
where &amp;amp;parameter_1 in ("&amp;amp;parameter_2");
var &amp;amp;_field;
run;&lt;/PRE&gt;</description>
    <pubDate>Thu, 18 May 2023 18:46:53 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2023-05-18T18:46:53Z</dc:date>
    <item>
      <title>Remove duplicates in proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-duplicates-in-proc-print/m-p/876541#M346291</link>
      <description>&lt;P&gt;In the following code, I want to remove the duplicates. If I want to add proc sort or proc sql to remove duplicates then how to tweak this code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let target_table=&amp;amp;datasource;
%global prompt;

proc print data="&amp;amp;envPath/data/gb/&amp;amp;datasource" noobs;
where &amp;amp;parameter_1 in ("&amp;amp;parameter_2");
var &amp;amp;_field;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 18:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-duplicates-in-proc-print/m-p/876541#M346291</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-18T18:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicates in proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-duplicates-in-proc-print/m-p/876550#M346293</link>
      <description>&lt;P&gt;You can add proc sort just before proc print. And you might need to specify exact variables in BY statement, if not interested in sorting all variables that listed in &amp;amp;_field macro variable.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let target_table=&amp;amp;datasource;
%global prompt;

proc sort data= "&amp;amp;envPath/data/gb/&amp;amp;datasource" out=sorted nodupkey /*or noduprecs if sorting all vars*/;
	by &amp;amp;_field /* or list of vars */;
run; 
proc print data= sorted noobs;
	where &amp;amp;parameter_1 in ("&amp;amp;parameter_2");
	var &amp;amp;_field;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 19:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-duplicates-in-proc-print/m-p/876550#M346293</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-05-18T19:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicates in proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-duplicates-in-proc-print/m-p/876563#M346296</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;In the following code, I want to remove the duplicates. If I want to add proc sort or proc sql to remove duplicates then how to tweak this code?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Duplicates of what? &amp;amp;parameter_1? &amp;amp;parameter_2? &amp;amp;_field?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Really need to learn to use libname.dataset notation. relying on external file syntax is going to cause problems at sometime.&lt;/P&gt;
&lt;P&gt;For one thing&amp;nbsp; you only have to debug ONE libname statement and have one assignment for the library. What you have could require changing lots of code when something moves or processing similar data in another location, such as to a different sub-folder like&lt;/P&gt;
&lt;PRE&gt;"&amp;amp;envPath/data/gb_2&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, do you want to use that data set for anything else? Ever? Especially needing it with the duplicates for that other use? Then your sort would require a different output data set(or view) for the Print step as otherwise the duplicates are &lt;STRONG&gt;permanently&lt;/STRONG&gt; gone.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 20:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-duplicates-in-proc-print/m-p/876563#M346296</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-18T20:50:02Z</dc:date>
    </item>
  </channel>
</rss>

