<?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: get test values within 60 days [+/-] of each othe in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537816#M6828</link>
    <description>&lt;P&gt;Thanks Neil.&lt;/P&gt;&lt;P&gt;This is exactly i need for my report. Thanks a lot for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeetender&lt;/P&gt;</description>
    <pubDate>Fri, 22 Feb 2019 19:06:33 GMT</pubDate>
    <dc:creator>jeetendersinghc</dc:creator>
    <dc:date>2019-02-22T19:06:33Z</dc:date>
    <item>
      <title>get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537755#M6810</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data labtest;
   informat t1date t2date  yymmdd10.;
   input patid t1date t2date t1result t2result;
   format t1date t2date yymmddD10.;
datalines;
001 2012-05-19 2012-05-21 20 25
001 2013-04-21 2012-07-08 14 38
001 2012-09-08 2012-07-08 22 23
001 2015-07-27 2012-07-31 65 34
001 	.	   2013-04-19  . 23
001  . 		   2013-04-19  . 32
001 .  		   2013-05-29  . 35
001  . 		   2014-06-30  . 54
001 .          2015-07-27  . 34


;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I need your help for above datasets.&lt;/P&gt;&lt;P&gt;I want to keep only those values &amp;nbsp;of test1 and test2&amp;nbsp; which are within 60 days [+/-] of each other. I tried by merging the datsets with PATID but i am getting note in my log" &lt;SPAN&gt;MERGE statement has more than one data set with repeats of BY values".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;jeetender&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 16:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537755#M6810</guid>
      <dc:creator>jeetendersinghc</dc:creator>
      <dc:date>2019-02-22T16:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537766#M6811</link>
      <description>Based on the above input data set, what would you expect as output?</description>
      <pubDate>Fri, 22 Feb 2019 17:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537766#M6811</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-22T17:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537768#M6813</link>
      <description>&lt;P&gt;For example if the test date for test1 is 8th sep2012 then i want the record for test2 which are with in +- 60 days&amp;nbsp; (8th july 2012 and 31july 2012.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537768#M6813</guid>
      <dc:creator>jeetendersinghc</dc:creator>
      <dc:date>2019-02-22T17:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537772#M6815</link>
      <description>&lt;P&gt;Pl refer this code. as i have these results in 2 different datasets .&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data labtest1;
   informat t1date   yymmdd10.;
   input patid t1date  t1result ;
   format t1date  yymmddD10.;
datalines;
001 2012-05-19  20 
001 2013-04-21  14
001 2012-09-08  22 
001 2015-07-27  65 



;
run;
proc sort ;
by patid;
run;


data labtest2;
   informat  t2date  yymmdd10.;
   input patid  t2date  t2result;
   format  t2date yymmddD10.;
datalines;
001 2012-05-21  25
001 2012-07-08  38
001 2012-07-08  23
001 2012-07-31  34
001 2013-04-19  23
001 2013-04-19   32
001 2013-05-29   35
001 2014-06-30  54
001 2015-07-27   34


;
run;

proc sort ;
by patid;
run;

data labs; 
merge  labtest1 (in=b) labtest2 (in=c);
by patid ;
if b and c and t1date-60 le t2date le t1date+60;
difference=abs(t1date-t2date);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537772#M6815</guid>
      <dc:creator>jeetendersinghc</dc:creator>
      <dc:date>2019-02-22T17:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537774#M6817</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/126364"&gt;@jeetendersinghc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;For example if the test date for test1 is 8th sep2012 then i want the record for test2 which are with in +- 60 days&amp;nbsp; (8th july 2012 and 31july 2012.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I understand that, what I don't know is how you want to format your results. Or what happens when a record belongs to two 60 day groups? Nothing you've posted answers that.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537774#M6817</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-22T17:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537775#M6818</link>
      <description>&lt;P&gt;I want to keep all those results which are falling under +-60 days windows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:38:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537775#M6818</guid>
      <dc:creator>jeetendersinghc</dc:creator>
      <dc:date>2019-02-22T17:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537793#M6820</link>
      <description>&lt;P&gt;One attempt then. Note that data steps cannot do many to many merges though so if you're only merging on ID and you have multiple ID's in each data set you won't get what you expect. But I'm still not sure what you're expecting. If this is not what you want, you do need to show what you expect based on the input data, which you also need to clarify since you've changed the scenario from your first post&lt;SPAN style="background-color: #eaeaea; white-space: pre;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data labs; 
merge  labtest1 (in=b) labtest2 (in=c);
by patid ;

if b and c;

days_diff = t2date - t1date;

if not ( -60 &amp;lt;= t2date - t1date &amp;lt;= 60) then delete; 

run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/126364"&gt;@jeetendersinghc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to keep all those results which are falling under +-60 days windows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 18:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537793#M6820</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-22T18:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537799#M6822</link>
      <description>&lt;P&gt;my research query states that&amp;nbsp; keep only those patients who has "Values of test1 and test2 within 60 days [+/-] of each other".&lt;/P&gt;&lt;P&gt;So i am expecting to keep value of test1 and test2 only if they are&amp;nbsp; with in 60 days to each other or else i cannot keep those records.&lt;/P&gt;&lt;P&gt;for example if test1 is conduted on 1st April then i need test2 value if it falls with in +60days(1June) or -60days(1feb) .&lt;/P&gt;&lt;P&gt;I belive you r right , i need to use many to many merge using proc sql which cannot be done through data merge statement.I would appreciate if you can help me.&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;jeetender&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 18:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537799#M6822</guid>
      <dc:creator>jeetendersinghc</dc:creator>
      <dc:date>2019-02-22T18:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537811#M6825</link>
      <description>&lt;P&gt;hi Jeetendra&lt;/P&gt;&lt;P&gt;PS below. this might help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;create table _cnt as&lt;BR /&gt;select a.*, b.*,&lt;BR /&gt;datdif(t1date,t2date,'act/act') as dif&lt;BR /&gt;from labtest1 as a full join labtest2 as b&lt;BR /&gt;on a.patid = b.patid;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc print data=_cnt (where=(dif between -60 and 60));&lt;BR /&gt;by patid;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 18:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537811#M6825</guid>
      <dc:creator>neil011</dc:creator>
      <dc:date>2019-02-22T18:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537812#M6826</link>
      <description>&lt;P&gt;Show it with the sample data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 19:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537812#M6826</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-22T19:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537816#M6828</link>
      <description>&lt;P&gt;Thanks Neil.&lt;/P&gt;&lt;P&gt;This is exactly i need for my report. Thanks a lot for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeetender&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 19:06:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537816#M6828</guid>
      <dc:creator>jeetendersinghc</dc:creator>
      <dc:date>2019-02-22T19:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: get test values within 60 days [+/-] of each othe</title>
      <link>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537830#M6831</link>
      <description>Mark Neil’s answer as the solution please.</description>
      <pubDate>Fri, 22 Feb 2019 19:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/get-test-values-within-60-days-of-each-othe/m-p/537830#M6831</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-22T19:40:31Z</dc:date>
    </item>
  </channel>
</rss>

