<?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 pick a collection's name if its time range meets a particular year: 2040 in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647049#M193605</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316738"&gt;@annypanny&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a way to do this.&lt;/P&gt;
&lt;P&gt;The prxchange function identifies in the year boundaries in the pattern of each collection name.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm="," dsd;
	input Sc_no $ Strategy $ Collection_name :$20.;
	datalines;
A0007,FLEXI,"Flexi 2035-37 (BLK)"
A0008,FLEXI,"itl      2037-39 (BLK)"
A0009,FLEXI,"cptl   2040-42 (BLK)"
A0010,FLEXI,"sen   2038-40 (BLK)"
;
run;

data want;
	set have;
	_low_bound  = prxchange('s/^.*(\d{2}\d{2})-\d{2}.*$/$1/i',1,Collection_name);
	_high_bound = prxchange('s/^.*(\d{2})\d{2}-(\d{2}).*$/$1$2/i',1,Collection_name);;
	if _low_bound &amp;lt;= year(today())+20 &amp;lt;= _high_bound then output;
	drop _:;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39333i24034340E21AB759/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;</description>
    <pubDate>Tue, 12 May 2020 11:14:24 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-05-12T11:14:24Z</dc:date>
    <item>
      <title>how to pick a collection's name if its time range meets a particular year: 2040 in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647041#M193603</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;
&lt;P&gt;suppose there is a collection table as below,&lt;/P&gt;
&lt;P&gt;Sc_no&amp;nbsp; Strategy&amp;nbsp; Collection_name&lt;/P&gt;
&lt;P&gt;A0007&amp;nbsp; &amp;nbsp;FLEXI&amp;nbsp; &amp;nbsp; Flexi 2035-37 (BLK)&lt;BR /&gt;A0008&amp;nbsp; &amp;nbsp;FLEXI&amp;nbsp; &amp;nbsp; itl&amp;nbsp; &amp;nbsp; &amp;nbsp; 2037-39 (BLK)&lt;BR /&gt;A0009&amp;nbsp; &amp;nbsp;FLEXI&amp;nbsp; &amp;nbsp; cptl&amp;nbsp; &amp;nbsp;2040-42 (BLK)&lt;BR /&gt;A0010&amp;nbsp; &amp;nbsp;FLEXI&amp;nbsp; &amp;nbsp; sen&amp;nbsp; &amp;nbsp;2038-40 (BLK)&lt;/P&gt;
&lt;P&gt;I have to calculate the year which is 20 years from run date. E.g if today’s date is 12MAY2020, then this step will give 2040. And it will pick only that collection whose time range meets 2040. Example from the above table, the last two rows i.e.,&amp;nbsp;cptl&amp;nbsp; 2040-42 (BLK),&amp;nbsp;sen&amp;nbsp; 2038-40 (BLK) the time ranges meets 2040. then this will be picked up automatically.&lt;/P&gt;
&lt;P&gt;How can I do that&lt;/P&gt;
&lt;P&gt;Thanks in advance &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 11:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647041#M193603</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-05-12T11:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to pick a collection's name if its time range meets a particular year: 2040 in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647049#M193605</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316738"&gt;@annypanny&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a way to do this.&lt;/P&gt;
&lt;P&gt;The prxchange function identifies in the year boundaries in the pattern of each collection name.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm="," dsd;
	input Sc_no $ Strategy $ Collection_name :$20.;
	datalines;
A0007,FLEXI,"Flexi 2035-37 (BLK)"
A0008,FLEXI,"itl      2037-39 (BLK)"
A0009,FLEXI,"cptl   2040-42 (BLK)"
A0010,FLEXI,"sen   2038-40 (BLK)"
;
run;

data want;
	set have;
	_low_bound  = prxchange('s/^.*(\d{2}\d{2})-\d{2}.*$/$1/i',1,Collection_name);
	_high_bound = prxchange('s/^.*(\d{2})\d{2}-(\d{2}).*$/$1$2/i',1,Collection_name);;
	if _low_bound &amp;lt;= year(today())+20 &amp;lt;= _high_bound then output;
	drop _:;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39333i24034340E21AB759/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 11:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647049#M193605</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-12T11:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to pick a collection's name if its time range meets a particular year: 2040 in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647056#M193607</link>
      <description>working for me, thanks a lot.</description>
      <pubDate>Tue, 12 May 2020 11:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647056#M193607</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-05-12T11:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to pick a collection's name if its time range meets a particular year: 2040 in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647058#M193608</link>
      <description>&lt;P&gt;You're welcome ! Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316738"&gt;@annypanny&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 11:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647058#M193608</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-12T11:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to pick a collection's name if its time range meets a particular year: 2040 in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647395#M193760</link>
      <description>&lt;P&gt;Hi mam&lt;/P&gt;
&lt;P&gt;it is running fine for this type of range 2040-42 but when I used 2040-2042, then the code is not returning anything. Can You help me in this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 10:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647395#M193760</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-05-13T10:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to pick a collection's name if its time range meets a particular year: 2040 in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647420#M193777</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316738"&gt;@annypanny&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have adapte the code to take into account this situation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm="," dsd;
	input Sc_no $ Strategy $ Collection_name :$40.;
	datalines;
A0007,FLEXI,"Flexi 2035-37 (BLK)"
A0008,FLEXI,"itl      2037-39 (BLK)"
A0009,FLEXI,"cptl   2040-42 (BLK)"
A0010,FLEXI,"sen   2038-40 (BLK)"
A0010,FLEXI,"sen   2038-2042 (BLK)"
;
run;

data want;
	set have;
	_low_bound  = prxchange('s/^.*(\d{2}\d{2})-\d{2}.*$/$1/i',1,Collection_name);
	
	/*Second year in format yy e.g. 2038-42 */
	if prxmatch('/^.*(\d{2})\d{2}-(\d{2})\D*$/i',Collection_name) then
		_high_bound = prxchange('s/^.*(\d{2})\d{2}-(\d{2}).*$/$1$2/i',1,Collection_name);

	/*Second year in format yyyy e.g. 2038-2042 */
	else if prxmatch('/^.*(\d{2})\d{2}-(\d{4})\D*$/i',Collection_name) then
		_high_bound = prxchange('s/^.*(\d{2})\d{2}-(\d{4}).*$/$2/i',1,Collection_name);
	
	if _low_bound &amp;lt;= year(today())+20 &amp;lt;= _high_bound then output;
	
	drop _:;
run;

proc print;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 11:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647420#M193777</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-13T11:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to pick a collection's name if its time range meets a particular year: 2040 in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647443#M193788</link>
      <description>it is working, thank you</description>
      <pubDate>Wed, 13 May 2020 12:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-pick-a-collection-s-name-if-its-time-range-meets-a/m-p/647443#M193788</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-05-13T12:27:22Z</dc:date>
    </item>
  </channel>
</rss>

