<?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: Counting the number of visits in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-visits/m-p/566479#M159209</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;
	merge test1 test2;
	by id;
	visits=svcdate&amp;lt;admdate;
run;

proc summary nway data=test3;
class id;
var visits;
 output out=totalvisits (drop=_:)
    sum=
    ;
 run;
 proc print label;
 id id;
 var visits;
 label visits="# of Visits";
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Jun 2019 02:08:55 GMT</pubDate>
    <dc:creator>ghosh</dc:creator>
    <dc:date>2019-06-17T02:08:55Z</dc:date>
    <item>
      <title>Counting the number of visits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-visits/m-p/566469#M159205</link>
      <description>&lt;P&gt;Hi SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I have acquired this SAS table:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-06-16 at 5.44.09 PM.png" style="width: 376px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30302i7AB3ED42B12BA9D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-06-16 at 5.44.09 PM.png" alt="Screen Shot 2019-06-16 at 5.44.09 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to count the number of visits for each ID. If the service_date(svcdate) is smaller than admission_date(admdate), then the number of visits should increase by 1. How do I accomplish this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My previous codes to get this table are as follow:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
	input svcdate : mmddyy10. id @@;
	format svcdate mmddyy10.;
	cards;
04/11/2008 1 06/29/2008 1 07/22/2008 1
03/05/2008 2 11/15/2008 2 01/04/2008 2
01/07/2008 3 04/05/2008 3 06/06/2008 3
;
run;

data test2;
	input admdate : mmddyy10. id @@;
	format admdate mmddyy10.;
	cards;
05/01/2008 1
08/01/2008 2
07/01/2008 3
;
run;

proc sort data=test1;
	by id svcdate;
run;

proc sort data=test2;
	by id admdate;
run;

data test3;
	merge test1 test2;
	by id;
run;
proc print data=test3; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thans!!!&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jun 2019 21:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-visits/m-p/566469#M159205</guid>
      <dc:creator>Xing</dc:creator>
      <dc:date>2019-06-16T21:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of visits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-visits/m-p/566470#M159206</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;
	merge test1 test2;
	by id;
	if first.id then count=0;
	if svcdate&amp;lt;admdate then count+1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Jun 2019 21:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-visits/m-p/566470#M159206</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-06-16T21:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of visits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-visits/m-p/566479#M159209</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;
	merge test1 test2;
	by id;
	visits=svcdate&amp;lt;admdate;
run;

proc summary nway data=test3;
class id;
var visits;
 output out=totalvisits (drop=_:)
    sum=
    ;
 run;
 proc print label;
 id id;
 var visits;
 label visits="# of Visits";
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jun 2019 02:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-number-of-visits/m-p/566479#M159209</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2019-06-17T02:08:55Z</dc:date>
    </item>
  </channel>
</rss>

