<?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: How to delete duplicate subjects for the data contain missing value? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/364726#M275065</link>
    <description>&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by SubjectID;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if &amp;nbsp;first.subjectid and last subjectid then output; else&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if age=. or race=. or highestgrade=. then delete;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2017 20:02:41 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-06-06T20:02:41Z</dc:date>
    <item>
      <title>How to delete duplicate subjects for the data contain missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/364715#M275064</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 121 subjects in total and they have questionnaire data in 3 time points (baseline, 6 month and 12 month). I found subject ID = 2031 has two baseline data, and I want to delete the one has age, race, education level missing value. Could you please help me with the code? Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Obs&lt;/TD&gt;&lt;TD&gt;SubjectID&lt;/TD&gt;&lt;TD&gt;VISIT&lt;/TD&gt;&lt;TD&gt;Age&lt;/TD&gt;&lt;TD&gt;Race&lt;/TD&gt;&lt;TD&gt;HighestGrade&lt;/TD&gt;&lt;TD&gt;InterviewerID&lt;/TD&gt;&lt;TD&gt;TodaysDate&lt;/TD&gt;&lt;TD&gt;Quality_Of_Life&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2031&lt;/TD&gt;&lt;TD&gt;Baseline&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;28&lt;/TD&gt;&lt;TD&gt;1-Nov-12&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2031&lt;/TD&gt;&lt;TD&gt;Baseline&lt;/TD&gt;&lt;TD&gt;55&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;28&lt;/TD&gt;&lt;TD&gt;1-Nov-12&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 06 Jun 2017 19:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/364715#M275064</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2017-06-06T19:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete duplicate subjects for the data contain missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/364726#M275065</link>
      <description>&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by SubjectID;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if &amp;nbsp;first.subjectid and last subjectid then output; else&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if age=. or race=. or highestgrade=. then delete;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2017 20:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/364726#M275065</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-06-06T20:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete duplicate subjects for the data contain missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/364743#M275066</link>
      <description>&lt;P&gt;try this&lt;/P&gt;
&lt;PRE&gt;data have ;
input id visit $ val1 val2 val3;
datalines;
1 Baseline . . .
1 Baseline 2 3 4
1 faseline . . .
2 Baseline . . .
;



proc sql;
delete  from have a 
where exists
(select * from have b
where a.id =b.id
and a.visit='Baseline'
group by id
having count(id)&amp;gt; 1)
and a.val1 = .
and a.val2 =.
and a.val3 = .;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jun 2017 20:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/364743#M275066</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-06T20:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete duplicate subjects for the data contain missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/364745#M275067</link>
      <description>&lt;P&gt;Schmuel's approach would work, but might require some changes (depending on what the data looks like on the 6 month and 12 month visits).&amp;nbsp; Assuming you have sorted your data set by SubjectID Visit DESCENDING Age:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by subjectID Visit descending Age;&lt;/P&gt;
&lt;P&gt;if first.visit;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are concerned about more than one duplicate, we might have to revisit how to subset properly.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2017 20:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/364745#M275067</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-06T20:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete duplicate subjects for the data contain missing value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/365181#M275068</link>
      <description>&lt;P&gt;Assuming, for each subject id, there is always exactly one record with non-missing age,race,highestgrade, then a single WHERE statement will work, no matter how many record is one or more of those variables missing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where n(age,race,highestgrade)=3;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 21:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-delete-duplicate-subjects-for-the-data-contain-missing/m-p/365181#M275068</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-06-07T21:02:05Z</dc:date>
    </item>
  </channel>
</rss>

