<?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 Problems with proc sort in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-proc-sort/m-p/856472#M338410</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am using proc sort by _all_&amp;nbsp; so that I can know if there is a duplicate records but SAS is producing a record at the dupout which is not a duplicate by _all_.&lt;/P&gt;&lt;P&gt;I have tried using nodupkey and nodup, but am getting the same result. My expectations is that by using _all_ , sas will sort by all variables within the each record. In the past someone raise the same issue in this community and someone suggested using first. and last. but will this works and how do I use first. and last. with _all_?&lt;/P&gt;&lt;P&gt;Is there any other way to sort by _All_ ?&amp;nbsp; Any help will be highly appreciated. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;proc sort data=t nodup dupout=bc;&lt;BR /&gt;by _all_ ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=y nodupkey dupout=z&lt;BR /&gt;by _all_ ;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2023 14:44:33 GMT</pubDate>
    <dc:creator>CathyVI</dc:creator>
    <dc:date>2023-01-31T14:44:33Z</dc:date>
    <item>
      <title>Problems with proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-proc-sort/m-p/856472#M338410</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am using proc sort by _all_&amp;nbsp; so that I can know if there is a duplicate records but SAS is producing a record at the dupout which is not a duplicate by _all_.&lt;/P&gt;&lt;P&gt;I have tried using nodupkey and nodup, but am getting the same result. My expectations is that by using _all_ , sas will sort by all variables within the each record. In the past someone raise the same issue in this community and someone suggested using first. and last. but will this works and how do I use first. and last. with _all_?&lt;/P&gt;&lt;P&gt;Is there any other way to sort by _All_ ?&amp;nbsp; Any help will be highly appreciated. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;proc sort data=t nodup dupout=bc;&lt;BR /&gt;by _all_ ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=y nodupkey dupout=z&lt;BR /&gt;by _all_ ;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 14:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-proc-sort/m-p/856472#M338410</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2023-01-31T14:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-with-proc-sort/m-p/856482#M338417</link>
      <description>&lt;P&gt;Are you 100% sure it's not a duplicate? As they say: "Nothing can put a knife in your back as good as your own data..."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) run sort:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=t out=t_sort;
by _all_ ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2)&amp;nbsp; execute "first-last" check:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t_sort_check;
set t_sort;
by _all_;
_compare_ = (first.&amp;lt;the name of the last variable in variables list&amp;gt; = last.&amp;lt;the name of the last variable in variables list&amp;gt;);
run;

data t_sort_checr_result;
set t_sort_check;
where compare_ = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(&lt;CODE class=" language-sas"&gt;&amp;lt;the name of the last variable in variables list&amp;gt;&lt;/CODE&gt;&amp;nbsp;- replace this with proper variable name from the dataset, if you have: var1, var2, var3, ..., varN - use varN)&lt;/P&gt;
&lt;P&gt;3) see what is in the&amp;nbsp;&lt;CODE class=" language-sas"&gt;t_sort_checr_result&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 15:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-with-proc-sort/m-p/856482#M338417</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-01-31T15:37:04Z</dc:date>
    </item>
  </channel>
</rss>

