<?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: Identifying Dates within Multiple Windows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585233#M166864</link>
    <description>&lt;P&gt;The issue with this is if a transaction falls within multiple windows it will create duplicates&lt;/P&gt;</description>
    <pubDate>Fri, 30 Aug 2019 15:03:53 GMT</pubDate>
    <dc:creator>lm12abh</dc:creator>
    <dc:date>2019-08-30T15:03:53Z</dc:date>
    <item>
      <title>Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585213#M166849</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do i convert the following to a variable i that can be any value? I am trying to flag transactions that exist within x number of window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if transaction_date &amp;gt;=REDRESS_WDW_START_1 and transaction_date &amp;lt;= REDRESS_WDW_end_1 then trans_inscope_check='Y';
		else if transaction_date &amp;gt;=REDRESS_WDW_START_2 and transaction_date &amp;lt;= REDRESS_WDW_end_2 then trans_inscope_check='Y';
			else if transaction_date &amp;gt;=REDRESS_WDW_START_3 and transaction_date &amp;lt;= REDRESS_WDW_end_3 then trans_inscope_check='Y';
				else if transaction_date &amp;gt;=REDRESS_WDW_START_4 and transaction_date &amp;lt;= REDRESS_WDW_end_4 then trans_inscope_check='Y';
					else if transaction_date &amp;gt;=REDRESS_WDW_START_5 and transaction_date &amp;lt;= REDRESS_WDW_end_5 then trans_inscope_check='Y';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Laurence&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 14:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585213#M166849</guid>
      <dc:creator>lm12abh</dc:creator>
      <dc:date>2019-08-30T14:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585219#M166852</link>
      <description>Put your date pairs in a separate table and then join to it with either a between or your '&amp;gt;= and &amp;lt;=' logic.  You'll then get all windows the date falls between.</description>
      <pubDate>Fri, 30 Aug 2019 14:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585219#M166852</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-08-30T14:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585222#M166855</link>
      <description>&lt;P&gt;Simplify your code by using arrays:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array start {5} redress_wdw_start1-redress_wdw_start5;
array end {5} redress_wdw_end1-redress_wdw_end5;
trans_inscope_check = "N";
do i = 1 to dim(start);
  if start{i} le transaction_date le end{i} then trans_inscope_check = "Y";
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Aug 2019 14:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585222#M166855</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-30T14:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585230#M166862</link>
      <description>&lt;P&gt;Thanks. This is closer but it still isn't right. will it cause issue if accounts have a different number of windows?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 14:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585230#M166862</guid>
      <dc:creator>lm12abh</dc:creator>
      <dc:date>2019-08-30T14:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585233#M166864</link>
      <description>&lt;P&gt;The issue with this is if a transaction falls within multiple windows it will create duplicates&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 15:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585233#M166864</guid>
      <dc:creator>lm12abh</dc:creator>
      <dc:date>2019-08-30T15:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585236#M166865</link>
      <description>&lt;P&gt;That's not possible.&amp;nbsp; All accounts must have the same number of windows.&amp;nbsp; In a SAS data set, all variables are part of all observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is possible that there are missing values for some start or end dates, on some observations.&amp;nbsp; To avoid extra processing, you can switch to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 1 to dim(start) until (trans_inscope_check='Y')&amp;nbsp;;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Aug 2019 15:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585236#M166865</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-08-30T15:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585247#M166872</link>
      <description>Simply use DISTINCT</description>
      <pubDate>Fri, 30 Aug 2019 15:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585247#M166872</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-08-30T15:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585260#M166879</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266053"&gt;@lm12abh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks. This is closer but it still isn't right. will it cause issue if accounts have a different number of windows?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Define what "isn't right". If you want specific help, supply usable data (data step with datalines) and what you expect as a result.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 15:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585260#M166879</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-30T15:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585269#M166884</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266053"&gt;@lm12abh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do i convert the following to a variable i that can be any value? I am trying to flag transactions that exist within x number of window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if transaction_date &amp;gt;=REDRESS_WDW_START_1 and transaction_date &amp;lt;= REDRESS_WDW_end_1 then trans_inscope_check='Y';
		else if transaction_date &amp;gt;=REDRESS_WDW_START_2 and transaction_date &amp;lt;= REDRESS_WDW_end_2 then trans_inscope_check='Y';
			else if transaction_date &amp;gt;=REDRESS_WDW_START_3 and transaction_date &amp;lt;= REDRESS_WDW_end_3 then trans_inscope_check='Y';
				else if transaction_date &amp;gt;=REDRESS_WDW_START_4 and transaction_date &amp;lt;= REDRESS_WDW_end_4 then trans_inscope_check='Y';
					else if transaction_date &amp;gt;=REDRESS_WDW_START_5 and transaction_date &amp;lt;= REDRESS_WDW_end_5 then trans_inscope_check='Y';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Laurence&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Does your code do what you expect? Your requirement of "exist within x number of window" sounds like you need to count something but since the above code assigns values to the &lt;STRONG&gt;same variable&lt;/STRONG&gt; you only have one value. I think that you might be intending to create &lt;STRONG&gt;five&lt;/STRONG&gt; variables such as trans_inscope_check1 to trans_inscope_check5 to check.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that instead of 'Y' it is much easier in most cases to deal with a numeric variable coded as 1 for true and 0 for false.&lt;/P&gt;
&lt;P&gt;Something like this perhaps (though&amp;nbsp;arrays for this would be cleaner)&lt;/P&gt;
&lt;PRE&gt;trans_inscope_check1 =  (REDRESS_WDW_START_1   &amp;lt;= transaction_date &amp;lt;= REDRESS_WDW_end_1);
trans_inscope_check2 =  (REDRESS_WDW_START_2   &amp;lt;= transaction_date &amp;lt;= REDRESS_WDW_end_2);
trans_inscope_check3 =  (REDRESS_WDW_START_3   &amp;lt;= transaction_date &amp;lt;= REDRESS_WDW_end_3);
trans_inscope_check4 =  (REDRESS_WDW_START_4   &amp;lt;= transaction_date &amp;lt;= REDRESS_WDW_end_4);
trans_inscope_check5 =  (REDRESS_WDW_START_5   &amp;lt;= transaction_date &amp;lt;= REDRESS_WDW_end_5);

check_count= sum( of trans_inscope_check:);
&lt;/PRE&gt;
&lt;P&gt;SAS will return a numeric 1 for "true" in the comparison and 0 for false.&lt;/P&gt;
&lt;P&gt;You can get the counts of true (or yes) by summing the variable, mean will give percentage of yes.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 16:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585269#M166884</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-30T16:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585549#M166996</link>
      <description>&lt;P&gt;You then lose the information of which window it falls under. Thanks for your help though, the other solution is the one im going to try.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Laurence&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 07:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585549#M166996</guid>
      <dc:creator>lm12abh</dc:creator>
      <dc:date>2019-09-02T07:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585551#M166997</link>
      <description>&lt;P&gt;Apologies I didn't mean to come across rude. It must be due to the missing data for some windows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;acc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trand date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wdw start 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wdw end 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wdw start 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wdw end 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wdw start 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wdw end 3&lt;/P&gt;&lt;P&gt;123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01mar2016&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;01jan2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01aug2016&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01jan2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01feb2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01dec2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 04apr2019&lt;/P&gt;&lt;P&gt;123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01mar2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;01jan2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01aug2016&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01jan2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01feb2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01dec2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 04apr2019&lt;/P&gt;&lt;P&gt;321&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01mar2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01mar2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01dec2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;321&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01jan 2019&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;01mar2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01dec2018&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 07:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585551#M166997</guid>
      <dc:creator>lm12abh</dc:creator>
      <dc:date>2019-09-02T07:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585555#M166999</link>
      <description>&lt;P&gt;Thanks, I thought about using the Boolean but for some reason I used a flag of 'Y' instead. Probably not best practice. Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 08:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585555#M166999</guid>
      <dc:creator>lm12abh</dc:creator>
      <dc:date>2019-09-02T08:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585556#M167000</link>
      <description>&lt;P&gt;All fixed now if was because of some windows that are ., needed to replace the missing value. Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Laurence&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 08:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/585556#M167000</guid>
      <dc:creator>lm12abh</dc:creator>
      <dc:date>2019-09-02T08:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Dates within Multiple Windows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/586070#M167266</link>
      <description>Then they aren't really duplicates.</description>
      <pubDate>Wed, 04 Sep 2019 12:08:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Dates-within-Multiple-Windows/m-p/586070#M167266</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-09-04T12:08:23Z</dc:date>
    </item>
  </channel>
</rss>

