<?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: compare one sets of dates with another sets of dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/compare-one-sets-of-dates-with-another-sets-of-dates/m-p/660783#M197692</link>
    <description>&lt;P&gt;Please:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;post data in usable form&lt;/LI&gt;
&lt;LI&gt;post the expected result with the data you&amp;nbsp; have posted&lt;/LI&gt;
&lt;LI&gt;reduce the data, so that is only shows all cases you have/expect&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Have you thought about normalizing the data? Having numbered columns is almost always a sign for bad data-design. In your case having two tables, one with ID and one infusion_date and the other table with ID and one labdate, &lt;STRONG&gt;maybe&lt;/STRONG&gt; a sql-merge could solve the problem.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jun 2020 04:53:19 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-06-17T04:53:19Z</dc:date>
    <item>
      <title>compare one sets of dates with another sets of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-one-sets-of-dates-with-another-sets-of-dates/m-p/660255#M197677</link>
      <description>&lt;P&gt;&lt;SPAN&gt;My dataset looks like below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;```&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ID  Date_of_infusion1  Date_of_infusion2...Date_of_infusion33  Labdate1   Labdate2  ...Labdate100
A     04/01/2016            08/06/2016               .         11/08/2017  10/21/2017      .
B     09/18/2015                .                    .         09/22/2015  09/30/2015      .
C     11/24/2015                .                    .         07/05/2015      .           .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;```&lt;/P&gt;&lt;P&gt;What I want to do: For each ID, if the labdate is after any of the infusion dates but within 4 months of that date(any infusiondate&amp;lt;=labdate&amp;lt;=the infusiondate+4months), then keep it; otherwise drop the labdate.&lt;/P&gt;&lt;P&gt;What I was trying to do: make 2 arrays,one for infusion dates one for labdates. Then create a "flag" variable associated with Labdate.&lt;/P&gt;&lt;P&gt;I wrote something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array infusion {*} date_of_infusion:;
array labdate {*} labdate:;
array flag {101} flag0-flag100;

do i= 1 to dim(labdate);
    do j=1 to dim(infusion);
    if infusion[j] ne . and infusion[j]&amp;lt;=labdate[i]&amp;lt;=intnx('month',infusion[j],4) then flag[i]=1;else flag[i]=0;
    end;
end; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the result doesn't look like something I want...&lt;/P&gt;&lt;P&gt;Any help is appreciated! Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 01:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-one-sets-of-dates-with-another-sets-of-dates/m-p/660255#M197677</guid>
      <dc:creator>maxy</dc:creator>
      <dc:date>2020-06-17T01:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: compare one sets of dates with another sets of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-one-sets-of-dates-with-another-sets-of-dates/m-p/660336#M197678</link>
      <description>&lt;P&gt;Assuming Each Flag variable corresponds to a Labdate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	array infusion {*} date_of_infusion:;
	array labdate {*} labdate:;
	array flag {101} flag0-flag100;


		do i= 1 to dim(labdate);
			do j=1 to dim(infusion);
				if infusion[j] ne . and infusion[j]&amp;lt; labdate[i]&amp;lt;=intnx('month',infusion[j],4) then
					do;
						flag[i]=1;
						leave;
					end;
				else flag[i]=0;
			end;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jun 2020 01:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-one-sets-of-dates-with-another-sets-of-dates/m-p/660336#M197678</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2020-06-17T01:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: compare one sets of dates with another sets of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-one-sets-of-dates-with-another-sets-of-dates/m-p/660437#M197680</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;otherwise drop the labdate&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;What does this mean? You can't drop a column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 02:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-one-sets-of-dates-with-another-sets-of-dates/m-p/660437#M197680</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-17T02:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: compare one sets of dates with another sets of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-one-sets-of-dates-with-another-sets-of-dates/m-p/660783#M197692</link>
      <description>&lt;P&gt;Please:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;post data in usable form&lt;/LI&gt;
&lt;LI&gt;post the expected result with the data you&amp;nbsp; have posted&lt;/LI&gt;
&lt;LI&gt;reduce the data, so that is only shows all cases you have/expect&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Have you thought about normalizing the data? Having numbered columns is almost always a sign for bad data-design. In your case having two tables, one with ID and one infusion_date and the other table with ID and one labdate, &lt;STRONG&gt;maybe&lt;/STRONG&gt; a sql-merge could solve the problem.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 04:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-one-sets-of-dates-with-another-sets-of-dates/m-p/660783#M197692</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-06-17T04:53:19Z</dc:date>
    </item>
  </channel>
</rss>

