<?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: Difference between dates across columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513765#M138472</link>
    <description>Hi! There are no missing or null values within completed values in test_date. So if there are three tests, then test_date1, test_date2, and test_date3 will all have values.&lt;BR /&gt;&lt;BR /&gt;I don’t have a good starting point for the 6-month period, this is my problem. If test_date1 is in 2012 but the test_date2 and test_date3 both occur in 2014 and 6 months or less apart, I want to flag the record as meeting the criteria.&lt;BR /&gt;</description>
    <pubDate>Fri, 16 Nov 2018 02:45:10 GMT</pubDate>
    <dc:creator>lstockman</dc:creator>
    <dc:date>2018-11-16T02:45:10Z</dc:date>
    <item>
      <title>Difference between dates across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513736#M138456</link>
      <description>&lt;P&gt;&lt;SPAN class="token procnames"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;Hello - I have a dataset of test dates for each&amp;nbsp;record in sequential order, earliest to latest. Some records have data in&amp;nbsp;up to 300 columns&amp;nbsp;(i.e. test_date1...test_date300), some have only one.&amp;nbsp;I need to add a new variable 'new_var' that indicates if there are two test_dates within a 6 month timespan. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token procnames"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;Does anyone have suggestions of an array that would calculate the span of time between the first test_date and the last test_date&amp;nbsp;and then count if there are two&amp;nbsp;dates, if there are new_var='Y'. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token procnames"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;Some sample data if useful. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; labs;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ID $ test_date1 test_date2 test_date3 test_date4 test_date5;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;101 08192010 . . . . .&lt;/P&gt;&lt;P&gt;102 01192010 01192010 11272014 07262016 09272016&lt;/P&gt;&lt;P&gt;103 02192011 02192013 12272014 . .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;Thank you!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 00:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513736#M138456</guid>
      <dc:creator>lstockman</dc:creator>
      <dc:date>2018-11-16T00:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513758#M138467</link>
      <description>&lt;P&gt;in you example you have ID 101 with only 1 date, but&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/162166"&gt;@lstockman&lt;/a&gt; wrote I could have 300 dates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will there be missing dates in the possible arrayed date-columns for an ID where date1 is not null but maybe date2-299 are null and then date300 has a date value?&lt;/P&gt;
&lt;P&gt;is the first found date1-300 in the array the start-date and the last date found the records to be evaluated?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please provide a few more datalines representing what you may have coming in.&lt;/P&gt;
&lt;P&gt;Please post a sample of your wants related to the datalines you post.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 02:05:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513758#M138467</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-16T02:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513765#M138472</link>
      <description>Hi! There are no missing or null values within completed values in test_date. So if there are three tests, then test_date1, test_date2, and test_date3 will all have values.&lt;BR /&gt;&lt;BR /&gt;I don’t have a good starting point for the 6-month period, this is my problem. If test_date1 is in 2012 but the test_date2 and test_date3 both occur in 2014 and 6 months or less apart, I want to flag the record as meeting the criteria.&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Nov 2018 02:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513765#M138472</guid>
      <dc:creator>lstockman</dc:creator>
      <dc:date>2018-11-16T02:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513769#M138475</link>
      <description>&lt;P&gt;this link may assist you with your wants&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/etsug/66100/HTML/default/viewer.htm#etsug_tsdata_sect057.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/etsug/66100/HTML/default/viewer.htm#etsug_tsdata_sect057.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you might want to place a do loop in the code to advance the lag date if you want to move the starting date value from date1 to date2... date299.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 03:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513769#M138475</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-16T03:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513775#M138478</link>
      <description>&lt;P&gt;replace the 5 with 300 if you have 300 columns and the 4 with your number of columns -1.&amp;nbsp; When new_var{I} = 1 then the dates being compared are 6 months apart.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data labs;
input ID $ test_date1: mmddyy8. test_date2: mmddyy8. test_date3: mmddyy8. test_date4: mmddyy8. test_date5: mmddyy8.;
datalines; 
101 08192010 . . . . .
102 01192010 01192010 11272014 07262016 09272016
103 02192011 02192013 12272014 . .
104 01012010 04012010 07012010 01052013 .
105 01012010 07102010 07012010 01052011 .
;
run;
data want;
	array test_date(5);
	array tmonth(5);
	array new_var(5);
	set labs;
	do j = 1 to 4;
		do i = j+1 to 5;
			tmonth{i} = (test_date{i}-test_date{j})/182.5;
			if tmonth{i} &amp;gt;= 1 then 
				do;
				new_var{i} = 1;
				end;
			if i = 5  and test_date{j} ne . then output;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 04:02:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/513775#M138478</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-16T04:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates across columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/514906#M138883</link>
      <description>&lt;P&gt;Thank you. Unfortunately, the tmonth calculation is not working quite right. I would like the tmonth calculation to be the difference in months&amp;nbsp;between&amp;nbsp;each test_date and the previous test_date. Then if tmonth &amp;lt;=6 months&amp;nbsp;then new_var=1. Does anyone know a modification? Also the code provided is outputting&amp;nbsp;multiple rows for each ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 19:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates-across-columns/m-p/514906#M138883</guid>
      <dc:creator>lstockman</dc:creator>
      <dc:date>2018-11-20T19:27:58Z</dc:date>
    </item>
  </channel>
</rss>

