<?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 variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550382#M152811</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp; &amp;nbsp;Please let us know the progress and mark the solution that you deem made you progress. Such encouragement helps up to keep playing this beautiful video game called SAS&lt;/P&gt;</description>
    <pubDate>Thu, 11 Apr 2019 19:37:37 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-04-11T19:37:37Z</dc:date>
    <item>
      <title>Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550024#M152685</link>
      <description>&lt;P&gt;Hi, I need some help with programming a counting procedure. Specifically, I am working with health record data and I need to create a binary variable (yes vs. no) for each patient in the data set to indicate the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-&amp;nbsp; whether the patient had 2 or more encounters separated by at least 90 days, but not more than 365 days, with Diagnosis "A"&lt;/P&gt;&lt;P&gt;Of note: the occurrence of the diagnosis can be present before 90 days of its last occurrence, but there must be at least 90 days between any two occurrences of the diagnosis.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any recommendations on how to code this using a data step procedure with a first.variable/last.variable statement would be much appreciated.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The other issue is not I have a a large group of diagnoses (~100) that I would like to do this for, and if ANY of the diagnoses within this group meets the condition above, then I would like to create a variable to indicate so. For example: IF diagnosis A=1 or diagnosis B=1 or diagnosis C=1.... then var=1. However, is there an efficient way of coding this other than doing the coding for the condition above for each diagnosis prior to combining ~100 of these conditions? Any suggestions for coding this would be much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an example of how my data set is organized. Each row represents a separate encounter for each patient.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Patient_ID&amp;nbsp;&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;diagnosis&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;diagnosis_date&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07JAN2015&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11FEB2016&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 04MAY2015&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07JAN2015&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07MAR2015&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 23FEB2017&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25FEB2018&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13JAN2016&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;F&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20OCT2014&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;T&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11NOV2013&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;E&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07JAN2015&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;R&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07JAN2015&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07FEB2016&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25APR2016&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02JUN2016&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 17:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550024#M152685</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-04-10T17:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550027#M152686</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp; If you could post the expected OUTPUT WANT sample for your sample INPUT while explaining the logic and why would help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 18:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550027#M152686</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-10T18:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550029#M152687</link>
      <description>&lt;P&gt;Please provide what you would expect the output data to look like as well. Since you setting a value based on multiple records there are several different ways the output might look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your second bit about different diagnosis is not very clear. Do you mean to compare Diagnosis=A with Diagnosis=B for the 90/ 365 day interval?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And for clarification of your 90 day rule does the following (NOT your example data)&lt;/P&gt;
&lt;PRE&gt;Patient_ID diagnosis diagnosis_date 
 1         A         07JAN2015
 1         A         11MAR2015
 1         A         14APR2015&lt;/PRE&gt;
&lt;P&gt;14Apr2015 count as more than 90 because it is more than 90 days from the 07JAN2015?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 18:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550029#M152687</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-10T18:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550031#M152689</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Yes, I would like the final expected output to include a variable (e.g., newvar) for each patient indicating whether any diagnosis within a specified group of diagnoses (let's say A, B, C, or D) meets the condition above. For example, if diagnosis A meets the condition for patient 1 and diagnosis B meets the condition for patient 3, then newvar=1 for both patients. So something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Patient_ID&amp;nbsp;&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;diagnosis&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;diagnosis_date&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newvar&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07JAN2015&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 23FEB2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02JUN2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;,&amp;nbsp;yes- your example would meet the 90 day rule since there are two occurrences of the diagnosis, and one occurrence (&lt;SPAN&gt;14Apr2015)&amp;nbsp;&lt;/SPAN&gt;is more than 90 days than another occurrence (&lt;SPAN&gt;07JAN2015)&lt;/SPAN&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you both for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 18:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550031#M152689</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-04-10T18:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550033#M152691</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Yes, I would like the final expected output to include a variable (e.g., newvar) for each patient indicating whether any diagnosis within a specified group of diagnoses (let's say A, B, C, or D) meets the condition above. For example, if diagnosis A meets the condition for patient 1 and diagnosis B meets the condition for patient 3, then newvar=1 for both patients. So something like this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Patient_ID&amp;nbsp;&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;diagnosis&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;diagnosis_date&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newvar&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07JAN2015&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 23FEB2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02JUN2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;,&amp;nbsp;yes- your example would meet the 90 day rule since there are two occurrences of the diagnosis, and one occurrence (&lt;SPAN&gt;14Apr2015)&amp;nbsp;&lt;/SPAN&gt;is more than 90 days than another occurrence (&lt;SPAN&gt;07JAN2015)&lt;/SPAN&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you both for the help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And if two (or more) separate diagnosis for a single patient&amp;nbsp;meet the condition what should the output look like.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 18:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550033#M152691</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-10T18:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550036#M152693</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;,&amp;nbsp;the output would also be newvar=1 if two or more&lt;SPAN&gt;&amp;nbsp;separate diagnoses for a single patient&amp;nbsp;meets the condition.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please let me know if any other clarification is needed.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 18:40:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550036#M152693</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-04-10T18:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550051#M152695</link>
      <description>&lt;P&gt;Ok.&lt;/P&gt;
&lt;P&gt;I thought i'd have more time to mock this up for you but nope.&amp;nbsp; So i will share what i have for now.&lt;/P&gt;
&lt;P&gt;This is the kind of healthcare data and work I do day in/out and know.&lt;/P&gt;
&lt;P&gt;Usually with VRDC CMS claims data and lots of it.&amp;nbsp; I am not posting this to start debates about uses (or not) of sql, merge, join.&lt;/P&gt;
&lt;P&gt;I'm simply crafting a possible solution to&amp;nbsp; your case/scenario and one which i feel is flexible if you have MORE than one diagnosis condition to seek and/or much more data to throw at it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you care to discuss further - reach back out.&amp;nbsp; But i'm pretty swamped leading up to SGF.&amp;nbsp; I'll be attending and presenting.&lt;/P&gt;
&lt;P&gt;I also live, work, code in Chicago.&amp;nbsp; Look me up via WCSUG.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So here is my code to share with you...&lt;/P&gt;
&lt;PRE&gt;/*** read mock data ***/&lt;BR /&gt;data work.test;
length pid $1.;
length diag_cd $1.;
length diag_dt 8.; format diag_dt yymmdd10.;
infile datalines ;
input pid $ diag_cd $ diag_dt date11.;
datalines;
1 A 07JAN2015
1 B 11FEB2016
1 A 04MAY2015
1 C 07JAN2015
1 B 07MAR2015
2 X 23FEB2017
2 X 25FEB2018
2 C 13JAN2016
2 F 20OCT2014
2 T 11NOV2013
3 E 07JAN2015
3 R 07JAN2015
3 B 07FEB2016
3 B 25APR2016
3 B 02JUN2016
;
run;

/*** create format per target set of diag conditions to find ***/&lt;BR /&gt;/*** this might be for allergies ***/
proc format;
invalue $dgtarga
"A" = 1
"A.1" = 1
"A.10" = 1
other = 0;
run;

/*** this might be for high blood pressure ***/
proc format;
invalue $dgtargb
"B" = 1
"B.3" = 1
"B.40" = 1
other = 0;
run;
&lt;BR /&gt;&lt;BR /&gt;/*** push that data thru the formats to identify which PID and thus dates to then check in next step ***/&lt;BR /&gt;/*** in this case since each target diag is different condition - i can separate out tables    ***/&lt;BR /&gt;/*** by keeping PID and date (of diag) - in my next step - i can run a min/max on the diff between dates for that PID ***/
data work.test_a (keep=pid diag_dt)
     work.test_b (keep=pid diag_dt);
set work.test;&lt;BR /&gt;&lt;BR /&gt;/*** if i have other diag groups to target - i'd just have more target vars ***/
format target_a 8.;
format target_b 8.;
target_a=input(diag_cd,$dgtarga.);
target_b=input(diag_cd,$dgtargb.);
if target_a=1 then output work.test_a;
if target_b=1 then output work.test_b;
run;
&lt;BR /&gt;/*** what i couldnt get to is the next step which transposes and/or does a by group (on pid) ***/&lt;BR /&gt;/*** for the days diff between the dates ***/


&lt;/PRE&gt;
&lt;P&gt;So again sorry i didnt get to more of this but i have a meeting coming up and a call that came in and snagged some of my time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;Zeke Torres&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.linkedin.com/in/zeketorres/" target="_blank" rel="noopener"&gt;LinkedIn&lt;/A&gt;&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>Wed, 10 Apr 2019 19:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550051#M152695</guid>
      <dc:creator>zekeT_sasaholic</dc:creator>
      <dc:date>2019-04-10T19:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550062#M152703</link>
      <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42844"&gt;@zekeT_sasaholic&lt;/a&gt;&amp;nbsp;for the start. I would be very interested for hearing your suggestions for coding the time interval criteria and including multiple diagnoses for this scenario as well. I am a new SAS user and I am most familiar with using first/last variable coding for counting, so an approach using that method would be preferable.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;: please let me know if you would like additional clarification for providing any suggestions on your end as well.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 20:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550062#M152703</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-04-10T20:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550063#M152704</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp; &amp;nbsp;I am afraid I haven't understood the required output well and so I was basically waiting for&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; to perhaps take the lead if he was working on it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So my understanding goes as follows,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the below table, the diff column, count. &lt;STRONG&gt;Are you able to make out where my thinking is going??&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It's one of those things that leads to assumptions when I do not have clear understanding .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.W" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Patient_ID&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;diagnosis&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;diagnosis_date&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;d&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Flag&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;count&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;diff&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="l data"&gt;A&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="l data"&gt;C&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="l data"&gt;B&lt;/TD&gt;
&lt;TD class="r data"&gt;07MAR2015&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;59&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="l data"&gt;A&lt;/TD&gt;
&lt;TD class="r data"&gt;04MAY2015&lt;/TD&gt;
&lt;TD class="r data"&gt;04MAY2015&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;117&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="l data"&gt;B&lt;/TD&gt;
&lt;TD class="r data"&gt;11FEB2016&lt;/TD&gt;
&lt;TD class="r data"&gt;11FEB2016&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;283&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="l data"&gt;T&lt;/TD&gt;
&lt;TD class="r data"&gt;11NOV2013&lt;/TD&gt;
&lt;TD class="r data"&gt;11NOV2013&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="l data"&gt;F&lt;/TD&gt;
&lt;TD class="r data"&gt;20OCT2014&lt;/TD&gt;
&lt;TD class="r data"&gt;20OCT2014&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;343&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="l data"&gt;C&lt;/TD&gt;
&lt;TD class="r data"&gt;13JAN2016&lt;/TD&gt;
&lt;TD class="r data"&gt;20OCT2014&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;450&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="l data"&gt;X&lt;/TD&gt;
&lt;TD class="r data"&gt;23FEB2017&lt;/TD&gt;
&lt;TD class="r data"&gt;20OCT2014&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;857&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="l data"&gt;X&lt;/TD&gt;
&lt;TD class="r data"&gt;25FEB2018&lt;/TD&gt;
&lt;TD class="r data"&gt;20OCT2014&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1224&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="l data"&gt;E&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="l data"&gt;R&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="l data"&gt;B&lt;/TD&gt;
&lt;TD class="r data"&gt;07FEB2016&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;396&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="l data"&gt;B&lt;/TD&gt;
&lt;TD class="r data"&gt;25APR2016&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;474&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="l data"&gt;B&lt;/TD&gt;
&lt;TD class="r data"&gt;02JUN2016&lt;/TD&gt;
&lt;TD class="r data"&gt;07JAN2015&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;512&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 10 Apr 2019 20:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550063#M152704</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-10T20:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550080#M152713</link>
      <description>&lt;P&gt;This may get a bit closer.&lt;/P&gt;
&lt;PRE&gt;data work.test;
length pid $1.;
length diag_cd $1.;
length diag_dt 8.; format diag_dt yymmdd10.;
infile datalines ;
input pid $ diag_cd $ diag_dt date11.;
datalines;
1 A 07JAN2015
1 B 11FEB2016
1 A 04MAY2015
1 C 07JAN2015
1 B 07MAR2015
2 X 23FEB2017
2 X 25FEB2018
2 C 13JAN2016
2 F 20OCT2014
2 T 11NOV2013
3 E 07JAN2015
3 R 07JAN2015
3 B 07FEB2016
3 B 25APR2016
3 B 02JUN2016
;
run;


proc sql;
   create table temp as
   select a.pid, a.diag_cd,a.diag_dt
          ,(90 le (b.diag_dt-a.diag_dt) le 365) as newvar
   from work.test as a
        join 
        work.test as b
        on a.pid=b.pid and a.diag_cd=b.diag_cd
   where a.diag_dt &amp;lt; b.diag_dt
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;The above code compares all values that match PID and DIAG_CD when the dates aren't the same. There can be multiple outputs and the more often a particular diag_cd is used the more output records. Rules for selecting which date(s) should appear in the output weren't supplied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This &lt;STRONG&gt;may&lt;/STRONG&gt; get what you want. If there is a newvar=1 then one of the possible many will be output.&lt;/P&gt;
&lt;PRE&gt;proc sort data=temp;
   by pid diag_cd descending newvar ;
run;

data want;
   set temp;
   by pid diag_cd;
   if first.pid;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Apr 2019 23:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550080#M152713</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-10T23:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550090#M152719</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;,&amp;nbsp;thank you for the suggestion! I will give this a try.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you be able to also provide a suggestion using a data step procedure with first/last variables? I am little more familiar with this approach as a newer SAS user.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To respond to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;'s comment: I have provided additional clarification below on what the output should be like. Please note diff should be the difference between diagnosis dates of the SAME diagnosis. Please also note that the criterion is that the variable will be counted if the difference between &lt;U&gt;ANY TWO&lt;/U&gt; diagnosis dates is &amp;gt;=90 days and &amp;lt;=365 days (not necessarily the difference between the earliest date and the last date). Please see Patient_ID 4 for an example of this scenario below (highlighted in red).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Patient_ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;diagnosis&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;diagnosis_date&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;d&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;diff&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;count&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;A&lt;/P&gt;&lt;/TD&gt;&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P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;03MAR2017&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;03MAR2017&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;0&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;0&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;01MAY2017&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;03MAR2017&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;59&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;0&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;15APR2018&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;01MAY2017&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;349&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 11 Apr 2019 00:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550090#M152719</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-04-11T00:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550105#M152723</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp; &amp;nbsp;OK got it. Thank you. It's almost bed time CST and I don't have SAS software at home. I'll work on this 1st thing in the morning i.e that is if nobody takes a stab at it. I honestly believe somebody would have solved while I'm sleeping. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 01:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550105#M152723</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-11T01:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550218#M152752</link>
      <description>&lt;P&gt;Good morning&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Patient_ID        diagnosis $      diagnosis_date  :date9.; 
format  diagnosis_date  date9.; 
cards;
      1                         A                  07JAN2015
      1                         B                 11FEB2016
      1                         A                  04MAY2015
      1                         C                  07JAN2015
      1                         B                  07MAR2015
      2                         X                  23FEB2017
      2                         X                  25FEB2018
      2                         C                 13JAN2016
      2                         F                  20OCT2014
      2                         T                   11NOV2013
      3                         E                  07JAN2015
      3                         R                  07JAN2015
      3                         B                  07FEB2016
      3                         B                  25APR2016
      3                         B                  02JUN2016
	  4	C	3-Mar-17	3-Mar-17
4	C	1-May-17	3-Mar-17
4	C	15-Apr-18	1-May-17
	  ;

	  
proc sql;
create table want as
select a.*,sum(90&amp;lt;=intck('days',a.diagnosis_date,b.diagnosis_date)&amp;lt;=365)&amp;gt;=2 as flag
from have a , have b
where a.Patient_ID=b.Patient_ID and a.diagnosis=b.diagnosis and b.diagnosis_date&amp;gt;a.diagnosis_date
group by a.patient_id
order by a.Patient_ID,a.diagnosis,diagnosis_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Apr 2019 13:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550218#M152752</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-11T13:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550224#M152753</link>
      <description>&lt;P&gt;And if you want the &lt;STRONG&gt;HAVE table as is in full&amp;nbsp;&lt;/STRONG&gt;, we switch to&lt;STRONG&gt; left join and distinct&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want1 as
select distinct a.*,sum(90&amp;lt;=intck('days',a.diagnosis_date,b.diagnosis_date)&amp;lt;=365)&amp;gt;=2 as flag
from have a left join have b
on a.Patient_ID=b.Patient_ID and a.diagnosis=b.diagnosis and b.diagnosis_date&amp;gt;a.diagnosis_date
group by a.patient_id
order by a.Patient_ID,a.diagnosis,diagnosis_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Apr 2019 13:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550224#M152753</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-11T13:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550241#M152757</link>
      <description>&lt;P&gt;A Datastep is of course more intuitive for its sequential process&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Patient_ID        diagnosis $      diagnosis_date  :date9.; 
format  diagnosis_date  date9.; 
cards;
      1                         A                  07JAN2015
      1                         B                 11FEB2016
      1                         A                  04MAY2015
      1                         C                  07JAN2015
      1                         B                  07MAR2015
      2                         X                  23FEB2017
      2                         X                  25FEB2018
      2                         C                 13JAN2016
      2                         F                  20OCT2014
      2                         T                   11NOV2013
      3                         E                  07JAN2015
      3                         R                  07JAN2015
      3                         B                  07FEB2016
      3                         B                  25APR2016
      3                         B                  02JUN2016
	  4	C	3-Mar-17	3-Mar-17
4	C	1-May-17	3-Mar-17
4	C	15-Apr-18	1-May-17
	  ;

	  proc sort data=have out=_have;
by Patient_ID diagnosis diagnosis_date;
run;

data want;
if _n_=1 then do;
if 0 then set have(rename=(diagnosis_date=d));
   dcl hash H (dataset:'have(rename=(diagnosis_date=d))',multidata:'y') ;
   h.definekey  ("Patient_ID","diagnosis") ;
   h.definedata ("d") ;
   h.definedone () ;
end;
set _have;
c=0;
by Patient_ID diagnosis ; 
if first.Patient_ID then c1=0;
do rc=h.find() by 0 while(rc=0);
if d&amp;gt;diagnosis_date and 90&amp;lt;=intck('days',diagnosis_date,d)&amp;lt;=365 then c+1;
rc=h.find_next();
end;
c1+c;
drop rc d;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 14:16:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550241#M152757</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-11T14:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550257#M152759</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;thank you very much! Pardon my ignorance, but how would I use the datastep approach to specify the diagnoses that I want to run the code for? For instance, I am only interested in identifying a select group of diagnoses that meet this condition- let's say diagnosis= A or B or C.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 14:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550257#M152759</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-04-11T14:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550277#M152762</link>
      <description>&lt;P&gt;well just subset using a filter(&amp;nbsp; &lt;STRONG&gt;where diagnosis in ('A','B','C')&lt;/STRONG&gt; ) and run the test against the subset&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 15:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550277#M152762</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-11T15:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550382#M152811</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp; &amp;nbsp;Please let us know the progress and mark the solution that you deem made you progress. Such encouragement helps up to keep playing this beautiful video game called SAS&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 19:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550382#M152811</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-11T19:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550404#M152814</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;Yes, thank you. I think the approach you suggested will be the way to go and I can mark it. I added the subset statement for specifying the variables as shown below; however, the issue that I am running into now is that after I run the code I am receiving an error message indicating there is insufficient memory to execute the data step program- also see below. The data set is very large and I will keep looking into this. Any suggestions regarding this matter would certainly be welcome as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; _n_&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;0&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;rename&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;diagnosis_date&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;d&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   dcl hash H &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dataset:&lt;SPAN class="token string"&gt;'have(rename=(diagnosis_date=d))'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;multidata:&lt;SPAN class="token string"&gt;'y'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   h&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;definekey  &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Patient_ID"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"diagnosis"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   h&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;definedata &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"d"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   h&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;definedone &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; _have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
c&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; Patient_ID diagnosis &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;BR /&gt;where diagnosis in ('A','B','C');
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;first&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Patient_ID &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; c1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
do rc&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;h&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;find&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;0&lt;/SPAN&gt; while&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;rc&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; d&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;diagnosis_date and &lt;SPAN class="token number"&gt;90&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'days'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;diagnosis_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;d&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;365&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; c&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
rc&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;h&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;find_next&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
c1&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;c&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;drop&lt;/SPAN&gt; rc d&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FATAL: Insufficient memory to execute DATA step program. Aborted during the EXECUTION phase.&lt;/P&gt;&lt;P&gt;ERROR: The SAS System stopped processing this step because of insufficient memory.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 20:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550404#M152814</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-04-11T20:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Counting variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550408#M152815</link>
      <description>&lt;P&gt;Jeez&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp; &amp;nbsp;How I wish that was never an issue. Good lord almighty. Well,&amp;nbsp; We will have to move away from hash as this is not the time for us to dig in and see how to fit all the data in memory or clear memory.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Let me work on a non hash solution. Don't mark anything yet as the thread is still open and not solved&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 20:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-variables/m-p/550408#M152815</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-11T20:29:59Z</dc:date>
    </item>
  </channel>
</rss>

