<?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: Excluding missing record where dependent variable has multiple rows of data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600354#M173516</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data one;
infile cards truncover;
input FirstName :$10.
 LastName : $10.
 cond_cd : $6.
;
datalines;
JOHN MCCARTHY
JOHN MCCARTHY TGCHS
JOHN MCCARTHY abcde
Akshay KUMAR
Akshay KUMAR TGCHS
SMITA PAREKH
;
run;
proc sort data=one;
by FirstName LastName;
run;
data want;
 set one;
 by FirstName LastName;
 if not (first.LastName and last.LastName) and missing(cond_cd) then delete;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 30 Oct 2019 12:20:29 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-10-30T12:20:29Z</dc:date>
    <item>
      <title>Excluding missing record where dependent variable has multiple rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600337#M173505</link>
      <description>&lt;P&gt;I have below piece of data and I want output in such a way that if a person has multiple rows of data then first blank value for cond_cd is removed from the output but if we have single row of data of person then blank value of cond_cd should remain.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;input &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159673"&gt;@001&lt;/a&gt; FirstName $10.&lt;BR /&gt;@011 LastName $10.&lt;BR /&gt;@021 cond_cd $6.&lt;BR /&gt;;&lt;BR /&gt;datalines;&lt;BR /&gt;JOHN MCCARTHY&lt;BR /&gt;JOHN MCCARTHY TGCHS&lt;BR /&gt;JOHN MCCARTHY abcde&lt;BR /&gt;Akshay KUMAR&lt;BR /&gt;Akshay KUMAR TGCHS&lt;BR /&gt;SMITA PAREKH&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired output =&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;FirstName LastName Cond_cd&lt;/U&gt;&lt;/P&gt;&lt;P&gt;JOHN MCCARTHY TGCHS&lt;BR /&gt;JOHN MCCARTHY abcde&lt;BR /&gt;Akshay KUMAR TGCHS&lt;BR /&gt;SMITA PAREKH&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 11:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600337#M173505</guid>
      <dc:creator>Abhinav26</dc:creator>
      <dc:date>2019-10-30T11:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding missing record where dependent variable has multiple rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600338#M173506</link>
      <description>&lt;P&gt;What if you had several blank values for some name?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 11:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600338#M173506</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-30T11:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding missing record where dependent variable has multiple rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600339#M173507</link>
      <description>&lt;P&gt;keep all of them&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 11:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600339#M173507</guid>
      <dc:creator>Abhinav26</dc:creator>
      <dc:date>2019-10-30T11:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding missing record where dependent variable has multiple rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600340#M173508</link>
      <description>&lt;P&gt;So if this was in your data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JOHN MCCARTHY&lt;BR /&gt;JOHN MCCARTHY&lt;BR /&gt;JOHN MCCARTHY TGCHS&lt;BR /&gt;JOHN MCCARTHY abcde&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you would want to keep all 4 obs?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 11:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600340#M173508</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-30T11:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding missing record where dependent variable has multiple rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600341#M173509</link>
      <description>&lt;P&gt;exclude the one's with blanks&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 11:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600341#M173509</guid>
      <dc:creator>Abhinav26</dc:creator>
      <dc:date>2019-10-30T11:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding missing record where dependent variable has multiple rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600342#M173510</link>
      <description>&lt;P&gt;One way. Provided that your data is gruoped by Names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input FirstName $ 1-6 LastName $ 8-15 cond_cd $ 17-21;
datalines;
JOHN   MCCARTHY      
JOHN   MCCARTHY TGCHS
JOHN   MCCARTHY abcde
Akshay KUMAR         
Akshay KUMAR    TGCHS
SMITA  PAREKH        
;

data want;
    do _N_=1 by 1 until (last.LastName);
        set one;
        by LastName notsorted;
    end;
    do until (last.LastName);
        set one;
        by LastName notsorted;
        if _N_=1 | (not missing(cond_cd) &amp;amp; _N_&amp;gt;1) then output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;FirstName   LastName   cond_cd
JOHN        MCCARTHY   TGCHS
JOHN        MCCARTHY   abcde
Akshay      KUMAR      TGCHS
SMITA       PAREKH          &lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2019 12:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600342#M173510</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-30T12:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding missing record where dependent variable has multiple rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600347#M173512</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data one;
infile cards truncover;
input FirstName :$10.
 LastName : $10.
 cond_cd : $6.
;
datalines;
JOHN MCCARTHY
JOHN MCCARTHY TGCHS
JOHN MCCARTHY abcde
Akshay KUMAR
Akshay KUMAR TGCHS
SMITA PAREKH
;
run;

proc sql;
create table want as
select *
from one
group by FirstName,LastName
having count(*)&amp;gt;1 and cond_cd ne ' ' or count(*)=1;
quit; 
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2019 12:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600347#M173512</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-10-30T12:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding missing record where dependent variable has multiple rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600354#M173516</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data one;
infile cards truncover;
input FirstName :$10.
 LastName : $10.
 cond_cd : $6.
;
datalines;
JOHN MCCARTHY
JOHN MCCARTHY TGCHS
JOHN MCCARTHY abcde
Akshay KUMAR
Akshay KUMAR TGCHS
SMITA PAREKH
;
run;
proc sort data=one;
by FirstName LastName;
run;
data want;
 set one;
 by FirstName LastName;
 if not (first.LastName and last.LastName) and missing(cond_cd) then delete;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2019 12:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excluding-missing-record-where-dependent-variable-has-multiple/m-p/600354#M173516</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-30T12:20:29Z</dc:date>
    </item>
  </channel>
</rss>

