<?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: Identify invalid data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-invalid-data/m-p/794357#M254709</link>
    <description>&lt;P&gt;FYI - I have updated your subject line to be more descriptive of your question. In the future please use an appropriate subject line.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see you've provided input data, what do you want as output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One function of interest is the DIF() function. It will calculate the difference between the current row and previous row. So if you calculate the dif for the date column you can then check if the dates are increasing or decreasing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also want to make sure your example data is representative of your problem. Do you have multiple patients for example? The code will change if you need to do it for multiple or just one. I'll leave that to you for now. An example of a possible solution is below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

days_diff = dif(visit_date);

if days_diff &amp;lt;0 then flag="ERROR";

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/399189"&gt;@sunilsan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;we have visit, visit_date, and pt (patient) variables or fields are there&lt;/P&gt;
&lt;P&gt;pt&amp;nbsp; &amp;nbsp; --&amp;nbsp; &amp;nbsp; &amp;nbsp;visit&amp;nbsp; &amp;nbsp;--&amp;nbsp; &amp;nbsp; &amp;nbsp; visit_date&lt;/P&gt;
&lt;P&gt;10005&amp;nbsp; &amp;nbsp; visit 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 09-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03-jan-2020&lt;/P&gt;
&lt;P&gt;requirement is the date entered is wrong,&lt;BR /&gt;the visit 1 date always smaller than visit 2 , same way visit 2 dae smaller than visit 3&lt;/P&gt;
&lt;P&gt;but here visit 4 date is date shd be gretaer than visit 3 ..&lt;BR /&gt;how to find these type of patient information date information in our raw data&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Feb 2022 20:53:23 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-02-03T20:53:23Z</dc:date>
    <item>
      <title>Identify invalid data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-invalid-data/m-p/794318#M254706</link>
      <description>&lt;P&gt;we have visit, visit_date, and pt (patient) variables or fields are there&lt;/P&gt;
&lt;P&gt;pt&amp;nbsp; &amp;nbsp; --&amp;nbsp; &amp;nbsp; &amp;nbsp;visit&amp;nbsp; &amp;nbsp;--&amp;nbsp; &amp;nbsp; &amp;nbsp; visit_date&lt;/P&gt;
&lt;P&gt;10005&amp;nbsp; &amp;nbsp; visit 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 09-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03-jan-2020&lt;/P&gt;
&lt;P&gt;requirement is the date entered is wrong,&lt;BR /&gt;the visit 1 date always smaller than visit 2 , same way visit 2 dae smaller than visit 3&lt;/P&gt;
&lt;P&gt;but here visit 4 date is date shd be gretaer than visit 3 ..&lt;BR /&gt;how to find these type of patient information date information in our raw data&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 20:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-invalid-data/m-p/794318#M254706</guid>
      <dc:creator>sunilsan</dc:creator>
      <dc:date>2022-02-03T20:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Identify invalid data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-invalid-data/m-p/794357#M254709</link>
      <description>&lt;P&gt;FYI - I have updated your subject line to be more descriptive of your question. In the future please use an appropriate subject line.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see you've provided input data, what do you want as output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One function of interest is the DIF() function. It will calculate the difference between the current row and previous row. So if you calculate the dif for the date column you can then check if the dates are increasing or decreasing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also want to make sure your example data is representative of your problem. Do you have multiple patients for example? The code will change if you need to do it for multiple or just one. I'll leave that to you for now. An example of a possible solution is below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

days_diff = dif(visit_date);

if days_diff &amp;lt;0 then flag="ERROR";

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/399189"&gt;@sunilsan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;we have visit, visit_date, and pt (patient) variables or fields are there&lt;/P&gt;
&lt;P&gt;pt&amp;nbsp; &amp;nbsp; --&amp;nbsp; &amp;nbsp; &amp;nbsp;visit&amp;nbsp; &amp;nbsp;--&amp;nbsp; &amp;nbsp; &amp;nbsp; visit_date&lt;/P&gt;
&lt;P&gt;10005&amp;nbsp; &amp;nbsp; visit 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 09-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02-jan-2020&lt;BR /&gt;10005&amp;nbsp; &amp;nbsp; visit 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03-jan-2020&lt;/P&gt;
&lt;P&gt;requirement is the date entered is wrong,&lt;BR /&gt;the visit 1 date always smaller than visit 2 , same way visit 2 dae smaller than visit 3&lt;/P&gt;
&lt;P&gt;but here visit 4 date is date shd be gretaer than visit 3 ..&lt;BR /&gt;how to find these type of patient information date information in our raw data&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 20:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-invalid-data/m-p/794357#M254709</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-03T20:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Identify invalid data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-invalid-data/m-p/794421#M254733</link>
      <description>&lt;P&gt;If PT was group variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
set have;

days_diff = dif(visit_date);

if pt=lag(pt) and days_diff &amp;lt;0 then flag="ERROR";

run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Feb 2022 07:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-invalid-data/m-p/794421#M254733</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-02-04T07:52:32Z</dc:date>
    </item>
  </channel>
</rss>

