<?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: two diagnosis within one year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280367#M56645</link>
    <description>&lt;P&gt;Since you are asking for ONE year, so make a group variable as year.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; group by id,year&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't want it, remove it&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; group by id&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Jun 2016 09:39:04 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-06-27T09:39:04Z</dc:date>
    <item>
      <title>two diagnosis within one year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280323#M56626</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stat480.temp2;
input id date dx1 dx2 dx3 dx4 dx5;
datalines;
1  1/1/2005 411 412 413 414 415
1 2/2/2005  411 412 413 414 415
2 1/1/2006  411 412 413 418 419
2  3/3/2006 420 421 422 423 424&lt;BR /&gt;3  3/4/2007 430 440 450 460 470&lt;BR /&gt;3  4/4/2007 430 510 520 530 560&lt;BR /&gt;;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi I have the following dataset. I am trying to find id who have at least 2 dx of 411 or 430 within one year (dx1-dx5) and keep them in the dataset, otherwise drop. For example output in this case would be keeping id 1 and 3&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 05:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280323#M56626</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-06-27T05:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: two diagnosis within one year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280328#M56630</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp2;
input id date : mmddyy10. dx1 dx2 dx3 dx4 dx5;
format  date  mmddyy10. ;
datalines;
1  1/1/2005 411 412 413 414 415
1 2/2/2005  411 412 413 414 415
2 1/1/2006  411 412 413 418 419
2  3/3/2006 420 421 422 423 424
3  3/4/2007 430 440 450 460 470
3  4/4/2007 430 510 520 530 560
;
run;

data have;
 set temp2;
 year=year(date);
run;
proc sql;
create table key as
 select id,year,sum(dx1 in (411,430)) as dx1,
                sum(dx2 in (411,430)) as dx2,
                sum(dx3 in (411,430)) as dx3,
                sum(dx4 in (411,430)) as dx4,
                sum(dx5 in (411,430)) as dx5,
sum(calculated dx1,calculated dx2,calculated dx3,calculated dx4,calculated dx5) as sum
  from have
   group by id,year
    having calculated sum ge 2;  
    
create table want as
 select * from have where id in (select id from key);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2016 06:18:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280328#M56630</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-27T06:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: two diagnosis within one year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280360#M56642</link>
      <description>&lt;P&gt;Thank you Xia, if I understand the coding correctly, if one dx was in 12/01/2005 and the other was in 01/01/2006, they will not be captured in your code? "even though they are still within one year"&amp;nbsp;&lt;/P&gt;&lt;P&gt;lilly&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 09:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280360#M56642</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-06-27T09:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: two diagnosis within one year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280367#M56645</link>
      <description>&lt;P&gt;Since you are asking for ONE year, so make a group variable as year.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; group by id,year&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't want it, remove it&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; group by id&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2016 09:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280367#M56645</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-27T09:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: two diagnosis within one year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280526#M56704</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;1  1/1/2005 411 412 413 414 415
1 2/2/2005  411 412 413 414 415
2 1/1/2006  411 412 413 418 419
2  3/3/2006 420 421 422 423 424
3  3/4/2007 430 440 450 460 470
3  12/4/2006 430 510 520 530 560&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If we modify the dates as above, your code will not capture id-3. I meant within one year that both codes appeared in less than a year from each other but not necessirly in the same year. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 18:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280526#M56704</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-06-27T18:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: two diagnosis within one year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280617#M56733</link>
      <description>&lt;P&gt;I don't understand what you mean.&lt;/P&gt;
&lt;P&gt;If there are many years in the same ID ( like 3), what you want ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What output it should be ( the data you posted)?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;  &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2005&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;411&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;412&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;413&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;414&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;415&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2005&lt;/SPAN&gt;  &lt;SPAN class="token number"&gt;411&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;412&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;413&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;414&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;415&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2006&lt;/SPAN&gt;  &lt;SPAN class="token number"&gt;411&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;412&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;413&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;418&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;419&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;  &lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2006&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;420&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;421&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;422&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;423&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;424&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;  &lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2007&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;430&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;440&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;450&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;460&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;470&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;  &lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2006&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;430&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;510&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;520&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;530&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;560&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want take ID and Year as two group variables?&lt;/P&gt;
&lt;P&gt;Then change the last SQL as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select * from have where catx(id,year) in (select &lt;SPAN&gt;catx(id,year) from key&lt;/SPAN&gt;) ;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 01:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/280617#M56733</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-28T01:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: two diagnosis within one year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/281144#M56953</link>
      <description>&lt;P&gt;Would still be 1 and 3. Your original code assume that the two dx should happen in the same year. But in reality one could happen in late 2004 and the other in early 2005 and still be one year apart. So I want to caputre these as well.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 15:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/281144#M56953</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-06-29T15:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: two diagnosis within one year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/281325#M57029</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;. But in reality one could happen in late 2004 and the other in early 2005 and still be one year apart."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So how do you define this kind of&amp;nbsp; one year apart ? How do I know which date belong to which year ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And Better to post some more data to explain your question.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 03:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/281325#M57029</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-30T03:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: two diagnosis within one year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/281523#M57109</link>
      <description>&lt;P class="p1"&gt;&lt;STRONG&gt;I've interpreted the question as wanting to keep all observation for an id if that id meets the condition of 2 or more occurrences of 411 or 430 within variables dx1-dx5 at anytime within any 12-month rolling period.&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;The flagged variable is used so that only one row for each id meeting the conditions output to the dataset 'idstokeep'.&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;I've &amp;nbsp;learned from this that the way the lag function behaves is affected by conditional expressions, and there has been some trial and error in getting to this.&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;Finally, a caveat. This may not work if a single observation has 2 occurrences of 411 or 430, or a value of 411 and 430. (eg DX1=411 &amp;amp; DX2=411, or DX1=411 &amp;amp; DX2=430).&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;If that is a real possibility then will need to make some changes.&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;data have;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;input id date : mmddyy10. dx1 dx2 dx3 dx4 dx5;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;format&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;date&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;mmddyy10. ;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;* ids 1, 3, 4 have had repeat readings of 411 or 430 in a 1-year period , so&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;all observations for these ids will be kept;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;datalines;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;1/1/2005 411 412 413 414 415&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;2/2/2005&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;411 412 413 414 415&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;11/1/2006&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;411 412 413 418 419&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3/3/2007 420 421 422 423 424&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;3&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;9/4/2006 430 440 450 460 470&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;3&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;6/4/2006 430 510 520 530 560&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;4&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3/4/2006 430 440 450 460 470&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;4&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;6/12/2006 432 510 520 530 560&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;4&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;9/14/2006 430 510 520 530 560&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;5&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3/4/2006 430 440 450 460 470&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;5&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;6/12/2006 432 510 520 530 560&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;5&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;4/14/2007 430 510 520 530 560&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;proc sort data=have; by id date;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;proc transpose data=have out=trans(where=(col1 in (411,430)));&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;by id date;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;data idstokeep (keep=id);&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;set trans;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;retain flagged;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;by id date;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;if first.id then flagged=0 ;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;if not first.id and INTCK('YEAR',lag(date),date,'C') =0 and flagged=0 then do;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;flagged=1;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;output;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;data want;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;merge idstokeep (in=idwanted) have;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;by id;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;if idwanted;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 17:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-diagnosis-within-one-year/m-p/281523#M57109</guid>
      <dc:creator>JohnHoughton</dc:creator>
      <dc:date>2016-06-30T17:18:21Z</dc:date>
    </item>
  </channel>
</rss>

