<?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: Multiple lines per patient extracted based on the presence of one observation among them in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-lines-per-patient-extracted-based-on-the-presence-of/m-p/275550#M7732</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
informat Patient_ID $3. Submitter_Name $15.;
input  Patient_ID $ Submitter_Name $; 
datalines; 
104 FamilyDoc
104 Corrections1
104 Hospital
106 FamilyDoc
106 Hospital 
108 Corrections2
108 Corrections2
108 Hospital
112 Hospital
112 Corrections3
112 Corrections3
117 Hospital
117 Hospital
;
run;

proc sql;
   create table want as
   select *
   from have
    group by Patient_ID
     having sum(Submitter_Name in ("Corrections1", "Corrections2", "Corrections3")) gt 0;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Jun 2016 02:28:50 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-06-07T02:28:50Z</dc:date>
    <item>
      <title>Multiple lines per patient extracted based on the presence of one observation among them</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-lines-per-patient-extracted-based-on-the-presence-of/m-p/275469#M7719</link>
      <description>&lt;P&gt;I am looking to make a subset of patients that at one point were tested at a correctional facility. Each patient number has multiple associated datalines (rows) but I wanted to extract all of them, even if they were only seen in my specified facilities once. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&amp;nbsp;&lt;/P&gt;&lt;P&gt;input &amp;nbsp;Patient_ID $ Submitter_Name $;&amp;nbsp;&lt;/P&gt;&lt;P&gt;datalines;&amp;nbsp;&lt;/P&gt;&lt;P&gt;104 FamilyDoc&lt;/P&gt;&lt;P&gt;104 Corrections1&lt;/P&gt;&lt;P&gt;104 Hospital&lt;/P&gt;&lt;P&gt;106 FamilyDoc&lt;/P&gt;&lt;P&gt;106 Hospital&amp;nbsp;&lt;/P&gt;&lt;P&gt;108 Corrections2&lt;/P&gt;&lt;P&gt;108 Corrections2&lt;/P&gt;&lt;P&gt;108 Hospital&lt;/P&gt;&lt;P&gt;112 Hospital&lt;/P&gt;&lt;P&gt;112 Corrections3&lt;/P&gt;&lt;P&gt;112 Corrections3&lt;/P&gt;&lt;P&gt;117 Hospital&lt;/P&gt;&lt;P&gt;117 Hospital&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to do is make a subset of only those patient IDs who were at one point tested in the facilities labelled "Corrections1, Corrections2, Corrections3". However, I need all lines from the associated patient ID. In this case, only the lines for patients 104, 108 and 112 should be output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with the code for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks! &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 17:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-lines-per-patient-extracted-based-on-the-presence-of/m-p/275469#M7719</guid>
      <dc:creator>mphqueens</dc:creator>
      <dc:date>2016-06-06T17:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines per patient extracted based on the presence of one observation among them</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-lines-per-patient-extracted-based-on-the-presence-of/m-p/275479#M7721</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
informat Patient_ID $3. Submitter_Name $15.;
input  Patient_ID $ Submitter_Name $; 

datalines; 
104 FamilyDoc
104 Corrections1
104 Hospital
106 FamilyDoc
106 Hospital 
108 Corrections2
108 Corrections2
108 Hospital
112 Hospital
112 Corrections3
112 Corrections3
117 Hospital
117 Hospital
;
run;

proc sql;
   create table want as
   select b.*
   from (select distinct Patient_ID from have where Submitter_Name in ( "Corrections1", "Corrections2", "Corrections3")) as a
        left join
        have as b on 
        a.Patient_ID = b.Patient_ID;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You didn't provide a length to the Submitter_name variable in the example that would hold the full text of the requested names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 17:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-lines-per-patient-extracted-based-on-the-presence-of/m-p/275479#M7721</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-06T17:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines per patient extracted based on the presence of one observation among them</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-lines-per-patient-extracted-based-on-the-presence-of/m-p/275485#M7722</link>
      <description>&lt;P&gt;This worked perfectly. Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 18:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-lines-per-patient-extracted-based-on-the-presence-of/m-p/275485#M7722</guid>
      <dc:creator>mphqueens</dc:creator>
      <dc:date>2016-06-06T18:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines per patient extracted based on the presence of one observation among them</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-lines-per-patient-extracted-based-on-the-presence-of/m-p/275550#M7732</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
informat Patient_ID $3. Submitter_Name $15.;
input  Patient_ID $ Submitter_Name $; 
datalines; 
104 FamilyDoc
104 Corrections1
104 Hospital
106 FamilyDoc
106 Hospital 
108 Corrections2
108 Corrections2
108 Hospital
112 Hospital
112 Corrections3
112 Corrections3
117 Hospital
117 Hospital
;
run;

proc sql;
   create table want as
   select *
   from have
    group by Patient_ID
     having sum(Submitter_Name in ("Corrections1", "Corrections2", "Corrections3")) gt 0;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jun 2016 02:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-lines-per-patient-extracted-based-on-the-presence-of/m-p/275550#M7732</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-07T02:28:50Z</dc:date>
    </item>
  </channel>
</rss>

