<?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: Help with pulling data from encounter based on date diference in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710501#M26793</link>
    <description>&lt;P&gt;1) As sas date contains the number of days since 01/01/1960 you can compute&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;daydif = enc_date - dx_date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; and you don't need the intck() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) As for assigning value to enc_want, I don't understand what do you mean by&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "&lt;SPAN&gt;complete BP and BMI data from encounter date closest prior to dx date within 15 days;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Can you explain by an example?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jan 2021 06:38:25 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2021-01-11T06:38:25Z</dc:date>
    <item>
      <title>Help with pulling data from encounter based on date diference</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710496#M26790</link>
      <description>&lt;P&gt;Hello SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to pull complete BP and BMI data from encounter date closest prior to dx date within 15 days; If none within 15 days then look back up to 30 days.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have:&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id enctype $ (enc_date dx_date)(:mmddyy10.) bp_sys 31-33 bp_dias 35-36 bmi 38-43 datawant 45-46;&lt;BR /&gt;format enc_date dx_date mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;3531 op 11/27/2016 11/27/2016 120 82&lt;BR /&gt;3531 gm 11/27/2016 11/27/2016 120 82 30.22&lt;BR /&gt;3590 ip 01/01/2017 01/25/2017 150 58 30.72&lt;BR /&gt;3590 gm 01/10/2017 01/25/2017 150 60 30.72&lt;BR /&gt;3590 op 01/24/2017 01/25/2017 150 59 30.11&lt;BR /&gt;3669 op 05/15/2011 06/08/2011 136 58&lt;BR /&gt;3669 op 06/08/2011 06/08/2011 126 60&lt;BR /&gt;3669 gm 06/15/2011 06/08/2011 112 58 28.78&lt;BR /&gt;3669 op 06/01/2011 06/08/2011&lt;BR /&gt;3695 ip 04/27/2014 05/14/2014 125 80&lt;BR /&gt;3695 op 05/21/2014 05/14/2014 125 70&lt;BR /&gt;3995 op 05/13/2014 05/14/2014 125 80&lt;BR /&gt;3995 gm 05/15/2014 05/14/2014 125 70&lt;BR /&gt;3744 op 01/02/2018 01/12/2018 114 60 28.96&lt;BR /&gt;3744 ip 01/10/2018 01/12/2018&lt;BR /&gt;4508 ip 08/12/2018 08/13/2018 162 84 31.6&lt;BR /&gt;4524 op 09/22/2017 09/12/2017 110 76 35.79&lt;BR /&gt;4704 gm 05/01/2011 05/03/2011 141 74 38.59&lt;BR /&gt;4704 op 05/02/2011 05/03/2011 128 70 38.04&lt;BR /&gt;7734 op 02/21/2011 02/21/2011&lt;BR /&gt;7734 op 07/07/2011 02/21/2011&lt;BR /&gt;7734 gm 02/20/2011 02/21/2011 132 64 41.35&lt;BR /&gt;8969 ip 03/08/2013 03/26/2013 140 86 31.48&lt;BR /&gt;8969 op 03/09/2013 03/26/2013 132 88 31.14&lt;BR /&gt;8969 op 02/08/2013 03/26/2013 158 80 32.39&lt;BR /&gt;8969 op 04/17/2013 03/26/2013 140 78 31.33&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data dave; set have;&lt;BR /&gt;daydiff=intck('day',dx_date,enc_date);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hanahchu_1-1610344345118.png" style="width: 512px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53377i48CD421EA6754DD3/image-dimensions/512x426?v=v2" width="512" height="426" role="button" title="hanahchu_1-1610344345118.png" alt="hanahchu_1-1610344345118.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help is greatly appreciated!&amp;nbsp; Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 05:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710496#M26790</guid>
      <dc:creator>hanahch</dc:creator>
      <dc:date>2021-01-11T05:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help with pulling data from encounter based on date diference</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710501#M26793</link>
      <description>&lt;P&gt;1) As sas date contains the number of days since 01/01/1960 you can compute&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;daydif = enc_date - dx_date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; and you don't need the intck() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) As for assigning value to enc_want, I don't understand what do you mean by&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "&lt;SPAN&gt;complete BP and BMI data from encounter date closest prior to dx date within 15 days;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Can you explain by an example?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 06:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710501#M26793</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-11T06:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help with pulling data from encounter based on date diference</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710654#M26795</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The goal is to pull the most complete vital data on bp_sys, bp_dias and BMI from an encounter that is closest within 15 days prior to dxdate. If an encounter closest to dxdate has the most missing data on all 3 variables then it needs to search the next records until the most complete vital data is found.&amp;nbsp; If no vital data within 15 days then it needs to search up to 30 days.&amp;nbsp; Below are some examples of cases that explained how I marked the encounters in the output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID 3531- the enc_date is not prior to dxdate --&amp;gt; do not mark as 1&lt;/P&gt;&lt;P&gt;ID 3590-closest encounter (1/24/2017) prior to dxdate with complete vital data --&amp;gt; mark as 1&lt;/P&gt;&lt;P&gt;ID 3669-no vital data within 15 days so look back 30 days. Enc_date 5/15/2011 has the most complete vital data&amp;nbsp; --&amp;gt;&amp;nbsp; mark as 1&lt;/P&gt;&lt;P&gt;ID &amp;nbsp;3695-no vital data within 15 days so look back 30 days.&amp;nbsp; Enc 4/272014 has the most complete vital data --&amp;gt; mark as 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope my explanation makes sense.&amp;nbsp; Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 18:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710654#M26795</guid>
      <dc:creator>hanahch</dc:creator>
      <dc:date>2021-01-11T18:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help with pulling data from encounter based on date diference</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710675#M26796</link>
      <description>&lt;P&gt;is this what you want?&lt;/P&gt;
&lt;PRE&gt;&lt;BR /&gt;data dave; set have;&lt;BR /&gt;daydiff=intck('day',dx_date,enc_date);&lt;BR /&gt;if abs(daydiff) le 15 then enc_want=1;&lt;BR /&gt;else if abs(daydiff) gt 15 and abs(daydiff) le 30 then enc_want=1;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;or does this one address what you need?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table close1 as&lt;BR /&gt;select *&lt;BR /&gt;from dave&lt;BR /&gt;where abs(daydiff) le 15;&lt;/P&gt;
&lt;P&gt;create table close2 as&lt;BR /&gt;select *&lt;BR /&gt;from dave&lt;BR /&gt;where abs(daydiff) gt 15 and abs(daydiff) le 30;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 19:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710675#M26796</guid>
      <dc:creator>anming</dc:creator>
      <dc:date>2021-01-11T19:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help with pulling data from encounter based on date diference</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710730#M26804</link>
      <description>&lt;P&gt;1) Please supply the test data as a data step not as a picture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
 set have; 
     daydif = dx_date - enc_date;
run;
proc sort data=have; by id enc_date; run;
data want;&lt;BR /&gt;  set temp;
  by id;
     if first.id then flag_out=0;
	 if daydif &amp;gt; 0 and flag_out=0 then do;
	    enc_wnat = 1;
		flag_out=1;
	 end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3) In case of any issue please explain it.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 06:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-with-pulling-data-from-encounter-based-on-date-diference/m-p/710730#M26804</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-12T06:11:53Z</dc:date>
    </item>
  </channel>
</rss>

