<?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 Compare observations within groups and find out the missing observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compare-observations-within-groups-and-find-out-the-missing/m-p/257751#M268951</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data which is as follows. I want to check the result mentioned for patient let's say 10001 -&amp;gt; Visit 1 -&amp;gt; Test No 1 -&amp;gt; Result with his every visit's Test no. 1 -&amp;gt; Result and if the Test is not performed for that particular visit or visit is missing then it should be flagged as a Missing Test or Missing Visit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E.g. - Patient 10001 -&amp;gt; Visit 1 -&amp;gt; Test No 1 -&amp;gt; Result with Patient 10001 -&amp;gt; Visit 2 -&amp;gt; Test No 1- &amp;gt; Result. Also, it should be checked with Visit 3 and so on (till the last visit's are present for the patient). The Patient 10001 has done 4 Tests in Visit 1 and 3 Tests in Visit 2 so his 4th Test is not mentioned or not performed then it should be flagged as 'Test 4 is absent' for the Visit 2. Also, if the Visit is not mentioned for the patient then it also should be flagged.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me out. Thank you very much in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2379i68E4AF102D1B144D/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="3.jpg" title="3.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Vikrant Sawatkar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 19 Mar 2016 10:06:43 GMT</pubDate>
    <dc:creator>VikrantSawatkar</dc:creator>
    <dc:date>2016-03-19T10:06:43Z</dc:date>
    <item>
      <title>Compare observations within groups and find out the missing observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-observations-within-groups-and-find-out-the-missing/m-p/257751#M268951</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data which is as follows. I want to check the result mentioned for patient let's say 10001 -&amp;gt; Visit 1 -&amp;gt; Test No 1 -&amp;gt; Result with his every visit's Test no. 1 -&amp;gt; Result and if the Test is not performed for that particular visit or visit is missing then it should be flagged as a Missing Test or Missing Visit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E.g. - Patient 10001 -&amp;gt; Visit 1 -&amp;gt; Test No 1 -&amp;gt; Result with Patient 10001 -&amp;gt; Visit 2 -&amp;gt; Test No 1- &amp;gt; Result. Also, it should be checked with Visit 3 and so on (till the last visit's are present for the patient). The Patient 10001 has done 4 Tests in Visit 1 and 3 Tests in Visit 2 so his 4th Test is not mentioned or not performed then it should be flagged as 'Test 4 is absent' for the Visit 2. Also, if the Visit is not mentioned for the patient then it also should be flagged.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me out. Thank you very much in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2379i68E4AF102D1B144D/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="3.jpg" title="3.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Vikrant Sawatkar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2016 10:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-observations-within-groups-and-find-out-the-missing/m-p/257751#M268951</guid>
      <dc:creator>VikrantSawatkar</dc:creator>
      <dc:date>2016-03-19T10:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Compare observations within groups and find out the missing observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-observations-within-groups-and-find-out-the-missing/m-p/257758#M268952</link>
      <description>&lt;P&gt;You didn't post the result yet.&lt;/P&gt;
&lt;P&gt;CODE NOT TESTED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select a.*,b.Result, missing(b.Result) as flag&lt;BR /&gt;    from
(
select * from
(select distinct PatientNumber from have),
(select distinct VisitNo from have),
(select distinct TestNo from have)
) as a
left join have as b
 on a.PatientNumber =b.PatientNumber and
      a.VisitNo =b.VisitNo  and
      a.TestNo =b.TestNo ;&lt;BR /&gt;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Mar 2016 11:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-observations-within-groups-and-find-out-the-missing/m-p/257758#M268952</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-19T11:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Compare observations within groups and find out the missing observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-observations-within-groups-and-find-out-the-missing/m-p/257760#M268953</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Are you saying you expect every patient to have records for all 3 visits, and all 4 tests done at each visit?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to approach this sort of problem is to build&amp;nbsp;a grid of all data you expect:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data expect;
  do patient=10001 to 10004;
    do visit=1 to 3;
      do test=1 to 4;
        output;
      end;
    end;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then&amp;nbsp;you can merge EXPECT against your HAVE data to identify any missing records, something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge expect (in=a)
        have   (in=b)
  ;
  by patient visit test;
  if a=0 then put "ERROR: record in have not expected " (patient visit test)(=);
  if b=0 then MissingRecord=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Mar 2016 11:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-observations-within-groups-and-find-out-the-missing/m-p/257760#M268953</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-03-19T11:38:56Z</dc:date>
    </item>
  </channel>
</rss>

