<?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: Select observations based on the matching year and the border months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-observations-based-on-the-matching-year-and-the-border/m-p/556736#M155117</link>
    <description>Great! Thank you very much!</description>
    <pubDate>Tue, 07 May 2019 11:27:25 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2019-05-07T11:27:25Z</dc:date>
    <item>
      <title>Select observations based on the matching year and the border months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-observations-based-on-the-matching-year-and-the-border/m-p/556632#M155070</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to subset data where&lt;/P&gt;
&lt;P&gt;1. year(date_diagnosis)=year(claim_date)&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;2. Oct, Nov and Dec of year before and Jan, Feb and Mar of year after the year(claim_date) to account for border months.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired output is the data with variable mark (1,0) where 1 indicating the data I'm gonna keep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for help. I greatly appreciate your time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA HAVE;
format PAT_ID 1. CLAIM_DATE date9. YEAR 4. MARK 1.; 
informat CLAIM_DATE date9. YEAR 4. MARK 1.; 
input PAT_ID CLAIM_DATE YEAR MARK; 
CARDS;
1	27-Dec-08	2011	0
1	19-Dec-09	2011	0
1	1-Jun-10	2011	0
1	1-Oct-10	2011	1
1	15-Nov-10	2011	1
1	1-Aug-11	2011	1
1	3-Jan-12	2011	1
1	5-Jan-12	2011	1
1	29-Dec-12	2011	0
2	2-May-14	2014	1
2	15-Oct-14	2014	1
2	13-Jan-15	2014	1
2	1-Feb-15	2014	1
2	18-Mar-15	2014	1
2	30-Sep-15	2014	0
2	1-Oct-15	2014	0
3	27-Dec-08	2011	0
3	15-Dec-09	2011	0
3	1-Jun-10	2011	0
3	1-Oct-10	2011	1
3	15-Nov-10	2011	1
3	1-Aug-11	2011	1
3	3-Jan-12	2011	1
3	2-Apr-12	2011	0
3	23-Nov-15	2011	0
3	5-Oct-16	2011	0
;

data have1; set have; 
claim_year=year(claim_date);
claim_month=month(claim_date);
run; 

proc print data=have1; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 02:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-observations-based-on-the-matching-year-and-the-border/m-p/556632#M155070</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-05-07T02:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Select observations based on the matching year and the border months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-observations-based-on-the-matching-year-and-the-border/m-p/556647#M155078</link>
      <description>&lt;P&gt;Would this work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
 	where mdy(10,1,year-1) &amp;lt;= CLAIM_DATE and mdy(3,31,year+1) &amp;gt;= CLAIM_DATE;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 May 2019 03:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-observations-based-on-the-matching-year-and-the-border/m-p/556647#M155078</guid>
      <dc:creator>heffo</dc:creator>
      <dc:date>2019-05-07T03:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select observations based on the matching year and the border months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-observations-based-on-the-matching-year-and-the-border/m-p/556659#M155087</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
DATA HAVE;
format PAT_ID 1. CLAIM_DATE date9. YEAR 4. ; 
informat CLAIM_DATE date9. YEAR 4. MARK 1.; 
input PAT_ID CLAIM_DATE YEAR MARK; 
drop mark;
CARDS;
1	27-Dec-08	2011	0
1	19-Dec-09	2011	0
1	1-Jun-10	2011	0
1	1-Oct-10	2011	1
1	15-Nov-10	2011	1
1	1-Aug-11	2011	1
1	3-Jan-12	2011	1
1	5-Jan-12	2011	1
1	29-Dec-12	2011	0
2	2-May-14	2014	1
2	15-Oct-14	2014	1
2	13-Jan-15	2014	1
2	1-Feb-15	2014	1
2	18-Mar-15	2014	1
2	30-Sep-15	2014	0
2	1-Oct-15	2014	0
3	27-Dec-08	2011	0
3	15-Dec-09	2011	0
3	1-Jun-10	2011	0
3	1-Oct-10	2011	1
3	15-Nov-10	2011	1
3	1-Aug-11	2011	1
3	3-Jan-12	2011	1
3	2-Apr-12	2011	0
3	23-Nov-15	2011	0
3	5-Oct-16	2011	0
;

data want;
set have;
by pat_id;
Mark=year(claim_date)=year-1  and  10&amp;lt;=month(claim_date)&amp;lt;=12 
or
year(claim_date)=year+1  and  1&amp;lt;=month(claim_date)&amp;lt;=3 
or
year= year(claim_date);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 May 2019 04:19:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-observations-based-on-the-matching-year-and-the-border/m-p/556659#M155087</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-05-07T04:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select observations based on the matching year and the border months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-observations-based-on-the-matching-year-and-the-border/m-p/556736#M155117</link>
      <description>Great! Thank you very much!</description>
      <pubDate>Tue, 07 May 2019 11:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-observations-based-on-the-matching-year-and-the-border/m-p/556736#M155117</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-05-07T11:27:25Z</dc:date>
    </item>
  </channel>
</rss>

