<?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 patient visits with two by groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/counting-patient-visits-with-two-by-groups/m-p/269234#M53330</link>
    <description>&lt;P&gt;Hi!&amp;nbsp; I am interested in ouputing a sum value to a new variable based on a condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. I have a table with 100 observations-&amp;nbsp; patientid with all their encounters.&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; I want to sum all married patients with ER visit in each year 2012- 2014 and output that sum by year to the last.patientid of each year.&lt;/P&gt;
&lt;P&gt;3. The end table should still have 100 observations...just with two new sum variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried, but my table keeps reducing to one patientid with ER sum or the table stays at 100 with the ER sum on each observation line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the last code i tried, but not correct.&amp;nbsp; Not&amp;nbsp; sure where to insert output statement (not correct here!) or if this type of do statement is possible??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA ER1_sum;&lt;BR /&gt;set var;&lt;BR /&gt;by patientid;&lt;BR /&gt;where&amp;nbsp; Marital_status='Married';&lt;BR /&gt;if ER1=1 then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if year='2012' then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if first.patientid=1 then n_ER12=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;n_ER12 +1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if last.patientid=1 then output;&lt;BR /&gt;&amp;nbsp;end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if year='2013' then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if first.patientid=1 then n_ER13=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;n_ER13 +1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if last.patientid=1 then output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if year='2014' then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if first.patientid=1 then n_ER14=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;n_ER14 +1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if last.patientid=1 then output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2016 17:19:49 GMT</pubDate>
    <dc:creator>jenim514</dc:creator>
    <dc:date>2016-05-09T17:19:49Z</dc:date>
    <item>
      <title>counting patient visits with two by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-patient-visits-with-two-by-groups/m-p/269234#M53330</link>
      <description>&lt;P&gt;Hi!&amp;nbsp; I am interested in ouputing a sum value to a new variable based on a condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. I have a table with 100 observations-&amp;nbsp; patientid with all their encounters.&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; I want to sum all married patients with ER visit in each year 2012- 2014 and output that sum by year to the last.patientid of each year.&lt;/P&gt;
&lt;P&gt;3. The end table should still have 100 observations...just with two new sum variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried, but my table keeps reducing to one patientid with ER sum or the table stays at 100 with the ER sum on each observation line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the last code i tried, but not correct.&amp;nbsp; Not&amp;nbsp; sure where to insert output statement (not correct here!) or if this type of do statement is possible??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA ER1_sum;&lt;BR /&gt;set var;&lt;BR /&gt;by patientid;&lt;BR /&gt;where&amp;nbsp; Marital_status='Married';&lt;BR /&gt;if ER1=1 then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if year='2012' then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if first.patientid=1 then n_ER12=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;n_ER12 +1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if last.patientid=1 then output;&lt;BR /&gt;&amp;nbsp;end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if year='2013' then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if first.patientid=1 then n_ER13=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;n_ER13 +1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if last.patientid=1 then output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if year='2014' then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if first.patientid=1 then n_ER14=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;n_ER14 +1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if last.patientid=1 then output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 17:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-patient-visits-with-two-by-groups/m-p/269234#M53330</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2016-05-09T17:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: counting patient visits with two by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-patient-visits-with-two-by-groups/m-p/269239#M53332</link>
      <description>&lt;P&gt;Provide some example input and what you want for output for that input.&lt;/P&gt;
&lt;P&gt;And are your sure that you need a dataset? This sounds like it should just be a report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also think that you mean to &lt;STRONG&gt;count&lt;/STRONG&gt; your patients as it is very difficult to "sum all married&amp;nbsp;patients".&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 17:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-patient-visits-with-two-by-groups/m-p/269239#M53332</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-09T17:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: counting patient visits with two by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/counting-patient-visits-with-two-by-groups/m-p/269250#M53335</link>
      <description>&lt;P&gt;Yes, count is correct.&amp;nbsp; I think I need a data set because i will need to build graphs later.&amp;nbsp; I think I can take out the marital status and just count the ER visits by year.&amp;nbsp; I can add a conditional statement later..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data for ER l is binary...if there was an ER visit the ER=1.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID 3. ER $ 1. Year $ 4.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;000&amp;nbsp; 0&amp;nbsp; 2012&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;000&amp;nbsp; 1&amp;nbsp; 2014 &amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;001&amp;nbsp; 1&amp;nbsp; 2012&amp;nbsp; &lt;/P&gt;
&lt;P&gt;001&amp;nbsp; 1&amp;nbsp; 2012&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;001&amp;nbsp; 0&amp;nbsp; 2013&amp;nbsp; &lt;/P&gt;
&lt;P&gt;001&amp;nbsp; 1&amp;nbsp; 2013&amp;nbsp; &lt;/P&gt;
&lt;P&gt;002&amp;nbsp; 1&amp;nbsp; 2012&amp;nbsp; &lt;/P&gt;
&lt;P&gt;002&amp;nbsp; 1&amp;nbsp; 2014&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;002&amp;nbsp; 1&amp;nbsp; 2014&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want to look like this...&lt;/P&gt;
&lt;P&gt;ID 3. ER $ 1. Year $ 4.&amp;nbsp; Marital $ 1. ER_12 1.&amp;nbsp; ER_13 1.&amp;nbsp;&amp;nbsp;ER_14&amp;nbsp; 1.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;000&amp;nbsp; 0&amp;nbsp; 2012 1 . . &lt;/P&gt;
&lt;P&gt;000&amp;nbsp; 1&amp;nbsp; 2014&amp;nbsp; . . 1&lt;/P&gt;
&lt;P&gt;001&amp;nbsp; 1&amp;nbsp; 2012&amp;nbsp; . . .&lt;/P&gt;
&lt;P&gt;001&amp;nbsp; 1&amp;nbsp; 2012&amp;nbsp; . . .&lt;/P&gt;
&lt;P&gt;001&amp;nbsp; 1&amp;nbsp; 2012 3 . .&lt;/P&gt;
&lt;P&gt;001&amp;nbsp; 0&amp;nbsp; 2013&amp;nbsp; . . .&lt;/P&gt;
&lt;P&gt;001&amp;nbsp; 1&amp;nbsp; 2013 .1 .&lt;/P&gt;
&lt;P&gt;002&amp;nbsp; 1&amp;nbsp; 2012 1. .&lt;/P&gt;
&lt;P&gt;002&amp;nbsp; 1&amp;nbsp; 2014 . . .&lt;/P&gt;
&lt;P&gt;002&amp;nbsp; 1&amp;nbsp; 2014 . . 2&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 17:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/counting-patient-visits-with-two-by-groups/m-p/269250#M53335</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2016-05-09T17:56:00Z</dc:date>
    </item>
  </channel>
</rss>

