<?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 counting encounters in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/counting-encounters/m-p/238753#M55446</link>
    <description>&lt;P&gt;Hi!&amp;nbsp; Want to create a table that counts the total days weteen first and last patient visit (ENCDATE)..variable 'Diff_Enc'&amp;nbsp;&amp;nbsp;and also a variable that counts total encounters 'Tot_Enc' &amp;nbsp;(one observation per&amp;nbsp;encounter).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; asthma.difference_vist;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; asthma.op_exclusion;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;by&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; patssn;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; first.patssn=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; and last.patssn=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;delete&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Diff_Enc=Encdate-LAG(encdate);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; not (first.patssn=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;Tot_Enc=encdate+&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;The DIFF_ENC gives forrect information, but the Tot_Enc jsut gives '.' in all values.&amp;nbsp; Can someone please let me know how to properly count the encounters?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks!!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Dec 2015 18:54:24 GMT</pubDate>
    <dc:creator>jenim514</dc:creator>
    <dc:date>2015-12-10T18:54:24Z</dc:date>
    <item>
      <title>counting encounters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-encounters/m-p/238753#M55446</link>
      <description>&lt;P&gt;Hi!&amp;nbsp; Want to create a table that counts the total days weteen first and last patient visit (ENCDATE)..variable 'Diff_Enc'&amp;nbsp;&amp;nbsp;and also a variable that counts total encounters 'Tot_Enc' &amp;nbsp;(one observation per&amp;nbsp;encounter).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; asthma.difference_vist;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; asthma.op_exclusion;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;by&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; patssn;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; first.patssn=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; and last.patssn=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;delete&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Diff_Enc=Encdate-LAG(encdate);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; not (first.patssn=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;Tot_Enc=encdate+&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;The DIFF_ENC gives forrect information, but the Tot_Enc jsut gives '.' in all values.&amp;nbsp; Can someone please let me know how to properly count the encounters?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks!!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 18:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-encounters/m-p/238753#M55446</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2015-12-10T18:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: counting encounters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-encounters/m-p/238759#M55447</link>
      <description>&lt;P&gt;Can you provide some sample data and what you expect in the output?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With what you have provided so far, I would say, use retain statements to save the first and last dates and then calculate the difference before writing to the output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good Luck....!!!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 19:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-encounters/m-p/238759#M55447</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-12-10T19:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: counting encounters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-encounters/m-p/238766#M55448</link>
      <description>&lt;P&gt;To get a single obs per patssn, do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data asthma.difference_vist;
Tot_Enc = 0;
do until (last.patssn);
	set asthma.op_exclusion; by patssn;
	if first.patssn then firstEnc = encDate;
	Tot_Enc + 1;
	end;
Diff_Enc = intck("DAY", firstEnc, encDate);
drop firstEnc;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 19:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-encounters/m-p/238766#M55448</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-12-10T19:38:28Z</dc:date>
    </item>
  </channel>
</rss>

