<?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: How to create a flag for each month lying between 2 dates. (Interpolation?) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/435149#M108057</link>
    <description>&lt;P&gt;Thank you however, dummy variables are needed because even if 2016 , 2017 were to be replaced , the array goes to 13 th&amp;nbsp;variable directly.&amp;nbsp; please correct if I am wrong here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code works thank you.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Feb 2018 02:10:03 GMT</pubDate>
    <dc:creator>vpgodbole</dc:creator>
    <dc:date>2018-02-08T02:10:03Z</dc:date>
    <item>
      <title>How to create a flag for each month lying between 2 dates. (Interpolation?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433331#M107411</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have claim number with Claim start date of 01 Jan 2017 and Claim closed date of 04th April 2017.&amp;nbsp;So, the months during which this claim was open are Jan, Feb and March.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My requirement is to create one variable for each month and year; i.e 12 variable in each year. This variable should be Flag=1&amp;nbsp;if the claim is&amp;nbsp;open during that month. The data i have for analysis comprises years 2016,2017 so at the most I am expecting 24 flags. Difference between dates should be reflected in the flags as =1 marked for each month its open. The closed month should not be flagged.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;About the file:&lt;/P&gt;&lt;P&gt;Its a flat file.&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clm_number&amp;nbsp; Clm_Start_Dt&amp;nbsp; &amp;nbsp;Clm_Closed_dt&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN2017&amp;nbsp; &amp;nbsp; &amp;nbsp; 04APR2017&lt;/P&gt;&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;29MAR2016&amp;nbsp; &amp;nbsp; 16AUG2016&lt;/P&gt;&lt;P&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;28NOV2016&amp;nbsp; &amp;nbsp; 08SEP2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am stuck here thinking how i can automate this and accommodate any year / any date. I am using SAS EG 5.1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you All and any feedback is appreciated!&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;Varun&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 00:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433331#M107411</guid>
      <dc:creator>vpgodbole</dc:creator>
      <dc:date>2018-02-02T00:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a flag for each month lying between 2 dates. (Interpolation?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433369#M107432</link>
      <description>&lt;P&gt;Hope it is what you want&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines;
input Clm_number @5 Clm_Start_Dt date9. @15 Clm_Closed_dt date9.;
format Clm_Start_Dt Clm_Closed_dt date9.;
datalines;
101 01JAN2017 04APR2017
102 29MAR2016 16AUG2016
;
run;

data want;
	set have;
	m_start=month(Clm_Start_Dt);
	m_end=month(Clm_Closed_dt)-1;
	array month(12) JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC;
	do i=m_start to m_end;
	    month(i)=1;
	end;
	drop m_start m_end i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Feb 2018 03:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433369#M107432</guid>
      <dc:creator>MINX</dc:creator>
      <dc:date>2018-02-02T03:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a flag for each month lying between 2 dates. (Interpolation?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433370#M107433</link>
      <description>&lt;P&gt;Worth trying:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;input claim Clm_start_dt : date9. Clm_closed_dt : date9.;&lt;/P&gt;
&lt;P&gt;format Clm_start_dt Clm_closed_dt date9.;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN2017&amp;nbsp; &amp;nbsp; &amp;nbsp; 04APR2017&lt;/P&gt;
&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;29MAR2016&amp;nbsp; &amp;nbsp; 16AUG2016&lt;/P&gt;
&lt;P&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;28NOV2016&amp;nbsp; &amp;nbsp; 08SEP2017&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array flags {24} flag_201501 - flag_201512 flag_201601 - flag_201612;&lt;/P&gt;
&lt;P&gt;start = 12 * (year(Clm_start_dt) - 2015) + month(Clm_start_dt);&lt;/P&gt;
&lt;P&gt;finish = 12 * (year(Clm_closed_dt) - 2015) + month(Clm_closed_dt);&lt;/P&gt;
&lt;P&gt;do k=start to finish - 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;flags{k} = 1;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop k start finish;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 04:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433370#M107433</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-02T04:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a flag for each month lying between 2 dates. (Interpolation?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433379#M107441</link>
      <description>&lt;P&gt;Thanks both... below code did the job, I just made first 12 dummy variables since i was getting this error 'ERROR: Array subscript out of range at line 28 column 4' :on submitting code mentioned by Astounding. also i changed the variable names of years to 16 and 17.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;array flags {*} dum1 - dum12 flag_201601 - flag_201612 flag_201701 - flag_201712;&lt;/P&gt;&lt;P&gt;start = 12 *(year(Clm_start_dt) - 2015) + month(Clm_start_dt) ;&lt;/P&gt;&lt;P&gt;finish = 12 * (year(Clm_closed_dt) - 2015) + month(Clm_closed_dt) ;&lt;/P&gt;&lt;P&gt;do k=start to (finish - 1) ;&lt;/P&gt;&lt;P&gt;flags{k} = 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;/*drop k start finish;*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I realized why 12 was multiplied, good idea, but then realized it was jumping to 13th var directly.&amp;nbsp;so created dummies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, to make it bit complicated.... what if a claim is closed but reopened again and closed again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ex.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clm_number&amp;nbsp; Clm_Start_Dt&amp;nbsp; &amp;nbsp; &amp;nbsp;Clm_Closed_Dt&amp;nbsp; &amp;nbsp; &amp;nbsp;Clm_Reopened_Dt&amp;nbsp; &amp;nbsp; &amp;nbsp;Clm_Closed_dt2&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;28NOV2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;08FEB2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 16JUN2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03AUG2017&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you again,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Varun&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 05:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433379#M107441</guid>
      <dc:creator>vpgodbole</dc:creator>
      <dc:date>2018-02-02T05:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a flag for each month lying between 2 dates. (Interpolation?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433417#M107449</link>
      <description>&lt;P&gt;For a reopened claim, add another loop at the end of the DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;start = 12 *(year(&lt;FONT color="#FF0000"&gt;Clm_reopened_dt&lt;/FONT&gt;) - 2015) + month(&lt;FONT color="#FF0000"&gt;Clm_reopened_dt&lt;/FONT&gt;) ;&lt;/P&gt;
&lt;P&gt;finish = 12 * (year(&lt;FONT color="#FF0000"&gt;Clm_closed_dt2&lt;/FONT&gt;) - 2015) + month(&lt;FONT color="#FF0000"&gt;Clm_closed_dt2&lt;/FONT&gt;) ;&lt;/P&gt;
&lt;P&gt;do k=start to (finish - 1) ;&lt;/P&gt;
&lt;P&gt;flags{k} = 1;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, you could eliminate the error message by a slight change to my original code, without adding 12 dummy variables.&amp;nbsp; Just change the formula to subtract 2016 instead of 2015.&amp;nbsp; That assumes that all dates fall into either 2016 or 2017.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 07:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/433417#M107449</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-02T07:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a flag for each month lying between 2 dates. (Interpolation?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/435149#M108057</link>
      <description>&lt;P&gt;Thank you however, dummy variables are needed because even if 2016 , 2017 were to be replaced , the array goes to 13 th&amp;nbsp;variable directly.&amp;nbsp; please correct if I am wrong here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code works thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 02:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/435149#M108057</guid>
      <dc:creator>vpgodbole</dc:creator>
      <dc:date>2018-02-08T02:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a flag for each month lying between 2 dates. (Interpolation?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/435153#M108058</link>
      <description>&lt;P&gt;The array can begin at the 1st element of the array.&amp;nbsp; It depends on what years are in the data set. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The formula that subtracts 2015 from the year assumes that the year will be at least 2015.&amp;nbsp; For 2015, the array begins with the 1st element, and for 2016 the array begins with the 13th element.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have more than 2 years of data in the data, you need more elements in the array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data contains just 2016 and 2017 data, the formula needs to change.&amp;nbsp; Subtract 2016 instead of 2015, and there won't be any dummy elements needed.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 02:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-dates/m-p/435153#M108058</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-08T02:28:20Z</dc:date>
    </item>
  </channel>
</rss>

