<?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: is there a way to drop duplicate rows while keeping rows that are not null values? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752251#M236933</link>
    <description>&lt;P&gt;In a PROC SORT that does change more than just the order, it is strongly recommended to use the OUT= option to create a new dataset and leave the source dataset untouched.&lt;/P&gt;
&lt;P&gt;Additionally, you can use the DUPOUT= option to store the filtered observations.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jul 2021 10:00:38 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-07-06T10:00:38Z</dc:date>
    <item>
      <title>is there a way to drop duplicate rows while keeping rows that are not null values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752242#M236930</link>
      <description>&lt;P&gt;I am currently working on a dataset that has duplicates in the primary key as shown in the example table I have given below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA = SAMPLE_TABLE NODUPKEY;&lt;BR /&gt;
BY ID_NO;&lt;BR /&gt;
RUN;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Dropping duplicates using the above snippet resulted in values being lost however. I would very much appreciate some advice on how to drop duplicates and preserve non-null values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 09:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752242#M236930</guid>
      <dc:creator>danielchoi626</dc:creator>
      <dc:date>2021-07-06T09:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to drop duplicate rows while keeping rows that are not null values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752251#M236933</link>
      <description>&lt;P&gt;In a PROC SORT that does change more than just the order, it is strongly recommended to use the OUT= option to create a new dataset and leave the source dataset untouched.&lt;/P&gt;
&lt;P&gt;Additionally, you can use the DUPOUT= option to store the filtered observations.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 10:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752251#M236933</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-06T10:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to drop duplicate rows while keeping rows that are not null values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752253#M236934</link>
      <description>&lt;P&gt;Sorry, but from your description it is not clear what you want to keep and what to drop. If you want to drop all obs having a missing value in id_no, then use a where statement.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 10:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752253#M236934</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-06T10:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to drop duplicate rows while keeping rows that are not null values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752296#M236947</link>
      <description>&lt;P&gt;It's relatively easy:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sample_table;
   by id_no;
run;

data want;
   update sample_table (obs=0) sample_table;
   by id_no;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For each ID_NO, this technique will use the last non-missing value for each variable.&amp;nbsp; Note, however, that you may still lose data.&amp;nbsp; It is conceivable that a variable has two different non-missing values in different observations.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 13:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752296#M236947</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-07-06T13:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to drop duplicate rows while keeping rows that are not null values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752350#M236969</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315610"&gt;@danielchoi626&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;This can be done as shown below. Modify as needed.&lt;BR /&gt;I have used your excel as the basis. In your&amp;nbsp; excel had amount as character. So I have added code to convert it to number.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Import your excel sheet */

PROC IMPORT DATAFILE='/home/yourfolder/SAMPLE DATA.xlsx'
	DBMS=XLSX
	OUT=WORK.IMPORT replace;
	GETNAMES=YES;
RUN;
/* Your amount was character.
I am converting  the amount to number. If in your original dataset amount is numeric, then this step not needed */
data import;
set import (Rename=(Amount=Amount_));
Amount=input(Amount_,best12.);
drop amount_;
run;

/* Remove duplicates*/
proc sql;
select distinct a.id_no, b.appl_no,b.Amount from import as a
left join import as b
on a.ID_no=b.ID_no
where b.amount is not missing
order by ID_no;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp; output will be as you wanted. The not null values from amount have been retained with no duplicates&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_0-1625588364899.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60994i6C68D57EAF6C1D81/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sajid01_0-1625588364899.png" alt="Sajid01_0-1625588364899.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Let me know if there are questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 16:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-drop-duplicate-rows-while-keeping-rows-that/m-p/752350#M236969</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-07-06T16:22:57Z</dc:date>
    </item>
  </channel>
</rss>

