<?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: Many dates comparison in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536422#M16548</link>
    <description>&lt;P&gt;Ok, I thougt it was possible to put all the dates in chronological order in a list and then to make a double do loop :&lt;/P&gt;&lt;P&gt;I = 1 to last column - 1&lt;/P&gt;&lt;P&gt;J=2 to last column&lt;/P&gt;&lt;P&gt;And then compare list[i] to list[j]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used that logic before with R software but I don't know SAS very well.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Feb 2019 09:51:07 GMT</pubDate>
    <dc:creator>sumsar</dc:creator>
    <dc:date>2019-02-18T09:51:07Z</dc:date>
    <item>
      <title>Many dates comparison</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536390#M16543</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I would like to create a macro which could compare all the dates of my database.&lt;BR /&gt;The idea is to create beforehand an unique dataset grouping all the dates of all the database in the chronological order.&lt;BR /&gt;For example, create a dataset with one line per subject grouping the date of birth, the date of consent, the date of follow-up and the date of end of study.&lt;BR /&gt;All my dates are in format DDMMYYYY10.&lt;BR /&gt;Subject_id Date_of_birth Date_of_consent Date_of_follow-up Date_of_end_of_study&lt;BR /&gt;1 xx/xx/xxxx xx/xx/xxxx xx/xx/xxxx xx/xx/xxxx&lt;BR /&gt;2 xx/xx/xxxx xx/xx/xxxx xx/xx/xxxx xx/xx/xxxx&lt;BR /&gt;3 xx/xx/xxxx xx/xx/xxxx xx/xx/xxxx xx/xx/xxxx&lt;/P&gt;&lt;P&gt;My idea is to create a macro which would compare all the dates and detect all the inconsitencies in one instruction.&lt;BR /&gt;In this example, the macro would compare the date of birth to the date of consent, then to the date of follow-up, and then to the end of study.&lt;BR /&gt;If one of this date is &amp;lt; to the date of birth, create a colomn "querie" in which is specified "Inconsistencies detected between dates".&lt;BR /&gt;Then do the same thing with the date of consent, compare it to the date of follow-up and then to the date of end of study and if one of this date is &amp;lt; to date of consent, specify in the column querie "Inconsistencies detected between dates".&lt;BR /&gt;Is there someone who has already made this or who could help me?&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 08:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536390#M16543</guid>
      <dc:creator>sumsar</dc:creator>
      <dc:date>2019-02-18T08:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Many dates comparison</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536402#M16544</link>
      <description>&lt;P&gt;There is no need (or in fact benefit) to create "a macro" or any other kind of fluff.&amp;nbsp; You have data with certain key attributes (going to assume patient id and visit) and dates.&amp;nbsp; So extract this information into one big dataset, proc sort nodupkey to get uniques, and then you can apply graphing, tabulating or program logic to look at this data.&lt;/P&gt;
&lt;PRE&gt;data bigdatesdataset;
  set dm (keep=usubjid startdate rename=(dob=startdate) in=a)
        dm (keep=usubjid startdate rename=(enrol=startdate) in=b)
        ae (keep=usubjid startdate enddate in=c)
        ...;
  if a then visit="Date of Birth";
  if b then visit="Enrolment";
  if c then visit="AE";
  ...;
run;&lt;/PRE&gt;
&lt;P&gt;You can get a nice long list of all the subjects/visits/dates - I use start/end so you can get period information or ranges - and then utilise that for checking.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 09:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536402#M16544</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-18T09:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Many dates comparison</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536403#M16545</link>
      <description>&lt;P&gt;You don't need a macro for this, you can create the code dynamically from sashelp.vcolumn:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set sashelp.vcolumn end=eof;
where libname = 'WORK' and memname = 'HAVE' and type = 'num' and format = 'DDMMYY10.' and upcase(name) ne 'DATE_OF_BIRTH';
if _n_ = 1 then call execute('data want; set have; length querie $100;';
call execute('if date_of_birth &amp;gt; ' !! name !! ' then querie = "' !! trim(name) !! ' is less than date_of_birth!";');
if eof then call execute('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Replace WORK and HAVE with you real library and mebmer names.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 09:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536403#M16545</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-18T09:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Many dates comparison</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536411#M16546</link>
      <description>&lt;P&gt;Thank you for your answer.&lt;/P&gt;&lt;P&gt;However, it seems that you compare all the dates to date of birth only, or I would like to compare all the dates between each other following their chronological order, I don't know if I'm clear.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 09:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536411#M16546</guid>
      <dc:creator>sumsar</dc:creator>
      <dc:date>2019-02-18T09:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Many dates comparison</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536419#M16547</link>
      <description>&lt;P&gt;Since you can't retrieve the "chronological order" from any resource, you have to hard-code the logic anyway. Trying to "automate" such a logic just leads to inflated and unmaintainable code.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 09:44:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536419#M16547</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-18T09:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Many dates comparison</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536422#M16548</link>
      <description>&lt;P&gt;Ok, I thougt it was possible to put all the dates in chronological order in a list and then to make a double do loop :&lt;/P&gt;&lt;P&gt;I = 1 to last column - 1&lt;/P&gt;&lt;P&gt;J=2 to last column&lt;/P&gt;&lt;P&gt;And then compare list[i] to list[j]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used that logic before with R software but I don't know SAS very well.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 09:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536422#M16548</guid>
      <dc:creator>sumsar</dc:creator>
      <dc:date>2019-02-18T09:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Many dates comparison</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536433#M16550</link>
      <description>&lt;P&gt;You can do that with an array, and you set the order in the array definition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array dates{*} Date_of_birth Date_of_consent Date_of_follow-up Date_of_end_of_study;
length querie $100;
do i = 1 to dim(dates);
  do j = i to dim (dates);
    if dates{i} &amp;gt; dates{j}
    then do;
      querie = vname(date{i}) !! ' is larger than ' !! vname(dates{j}) !! '!';
      output;
    end;
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Feb 2019 11:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536433#M16550</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-18T11:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Many dates comparison</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536457#M16551</link>
      <description>&lt;P&gt;Thank you, it works perfectly!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 12:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Many-dates-comparison/m-p/536457#M16551</guid>
      <dc:creator>sumsar</dc:creator>
      <dc:date>2019-02-18T12:48:28Z</dc:date>
    </item>
  </channel>
</rss>

