<?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 within an ARRAY in DATA steps (adding across a single observation) in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Counting-within-an-ARRAY-in-DATA-steps-adding-across-a-single/m-p/122469#M10125</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am currently attempting to use a number of different definitions to identify cancer cases in claims data.&amp;nbsp; In this definition, I would like to require that TWO OR MORE of the diagnosis fields (dx1 - dx15) be related to cancer.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been using a simple array to identify when ONE OR MORE of the dx fields were related to cancer:&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;ARRAY surgINdx(15) $ dx1-dx15;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&amp;nbsp; DO r=1 to 15;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&amp;nbsp; IF surgINdx(r) IN("162%" "2312%") &lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&amp;nbsp; THEN rDX=1;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&amp;nbsp; ELSE rDX = 0;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;END;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is this: how can I command my output variable rDX to be a count of the number of dx fields that were cancer related, rather than identifying if any of them were cancer related?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was hoping to use the code below but for some reason, everybody ends up with rDX = 0.&amp;nbsp; I figured I'd preset all rDX to 0, then add 1 each time that dx1 through dx15 is a cancer related code.&amp;nbsp; Can somebody point out to me what is wrong?&amp;nbsp; The log looks good.&amp;nbsp; No errors or anything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; *INPATIENT*;&lt;/P&gt;&lt;P&gt;DATA hw3.lungSURGin;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET all_inclaims;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rDX=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ARRAY surgINdx(15) $ dx1-dx15;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DO r=1 to 15;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF surgINdx(r) IN("162%" "2312%") &lt;/P&gt;&lt;P&gt;&amp;nbsp; THEN rDX+1; &lt;/P&gt;&lt;P&gt;&amp;nbsp; ELSE rDX+0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*REGARDLESS OF WHETHER I USE PROC SQL OR PROC PRINT, THERE ARE NO OBSERVATIONS WHERE rDX &amp;gt; 1*;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;select count(distinct enrolid) as cases_surgIN&lt;/P&gt;&lt;P&gt;from hw3.lungSURGin&lt;/P&gt;&lt;P&gt;WHERE rdx &amp;gt; 1;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC PRINT DATA=hw3.lungSURGin (OBS=100);&lt;/P&gt;&lt;P&gt;WHERE rDX&amp;gt;1;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Feb 2013 04:12:18 GMT</pubDate>
    <dc:creator>mconover</dc:creator>
    <dc:date>2013-02-27T04:12:18Z</dc:date>
    <item>
      <title>Counting within an ARRAY in DATA steps (adding across a single observation)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Counting-within-an-ARRAY-in-DATA-steps-adding-across-a-single/m-p/122469#M10125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am currently attempting to use a number of different definitions to identify cancer cases in claims data.&amp;nbsp; In this definition, I would like to require that TWO OR MORE of the diagnosis fields (dx1 - dx15) be related to cancer.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been using a simple array to identify when ONE OR MORE of the dx fields were related to cancer:&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;ARRAY surgINdx(15) $ dx1-dx15;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&amp;nbsp; DO r=1 to 15;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&amp;nbsp; IF surgINdx(r) IN("162%" "2312%") &lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&amp;nbsp; THEN rDX=1;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&amp;nbsp; ELSE rDX = 0;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;END;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is this: how can I command my output variable rDX to be a count of the number of dx fields that were cancer related, rather than identifying if any of them were cancer related?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was hoping to use the code below but for some reason, everybody ends up with rDX = 0.&amp;nbsp; I figured I'd preset all rDX to 0, then add 1 each time that dx1 through dx15 is a cancer related code.&amp;nbsp; Can somebody point out to me what is wrong?&amp;nbsp; The log looks good.&amp;nbsp; No errors or anything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; *INPATIENT*;&lt;/P&gt;&lt;P&gt;DATA hw3.lungSURGin;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET all_inclaims;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rDX=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ARRAY surgINdx(15) $ dx1-dx15;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DO r=1 to 15;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF surgINdx(r) IN("162%" "2312%") &lt;/P&gt;&lt;P&gt;&amp;nbsp; THEN rDX+1; &lt;/P&gt;&lt;P&gt;&amp;nbsp; ELSE rDX+0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*REGARDLESS OF WHETHER I USE PROC SQL OR PROC PRINT, THERE ARE NO OBSERVATIONS WHERE rDX &amp;gt; 1*;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;select count(distinct enrolid) as cases_surgIN&lt;/P&gt;&lt;P&gt;from hw3.lungSURGin&lt;/P&gt;&lt;P&gt;WHERE rdx &amp;gt; 1;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC PRINT DATA=hw3.lungSURGin (OBS=100);&lt;/P&gt;&lt;P&gt;WHERE rDX&amp;gt;1;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 04:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Counting-within-an-ARRAY-in-DATA-steps-adding-across-a-single/m-p/122469#M10125</guid>
      <dc:creator>mconover</dc:creator>
      <dc:date>2013-02-27T04:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Counting within an ARRAY in DATA steps (adding across a single observation)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Counting-within-an-ARRAY-in-DATA-steps-adding-across-a-single/m-p/122470#M10126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My numbers are really low.&amp;nbsp; I'm starting to wonder if the coding is actually right and there are just no cases that meet my definition...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 04:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Counting-within-an-ARRAY-in-DATA-steps-adding-across-a-single/m-p/122470#M10126</guid>
      <dc:creator>mconover</dc:creator>
      <dc:date>2013-02-27T04:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Counting within an ARRAY in DATA steps (adding across a single observation)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Counting-within-an-ARRAY-in-DATA-steps-adding-across-a-single/m-p/122471#M10127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First your IF condition looks wrong.&amp;nbsp; Are you thinking that the percent sign is going to be treated like a wildcard?&lt;/P&gt;&lt;P&gt;Perhaps you want to use the : modifier on the IN operator instead.&amp;nbsp; This will allow DX codes like '1621' to match.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;rdx=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;array surgindx dx1-dx15;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;do r=1 to dim(surgindx);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if surgindx(r) in: ('162' '2312') then rdx+1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;end;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 05:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Counting-within-an-ARRAY-in-DATA-steps-adding-across-a-single/m-p/122471#M10127</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-02-27T05:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Counting within an ARRAY in DATA steps (adding across a single observation)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Counting-within-an-ARRAY-in-DATA-steps-adding-across-a-single/m-p/122472#M10128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;mconover, I also work in the health care industry (health insurance) and frequently have to run reports populated by summarized data similar to what you are trying to do here. However, I only use Enterprise Guide and the query builder tool as I am not yet very familiar with the SAS code syntax (I am a programmer at heart but haven't learned the SAS ropes yet).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that the code Tom posted should work just fine, but if you are interested in building this utilizing the EG query builder consider using a case statement to populated a calculated column:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;CASE WHEN t1.surgindx LIKE '162' OR LIKE '2312' THEN 1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE 0&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;END&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Once you create this calculated column drag it into the selected column area in the query builder and SUM the field. The output should be a count of every claim that is related to cancer. If you do not sum the calculated column then the output will just be a list of flags (also useful sometimes depending on your situation).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 17:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Counting-within-an-ARRAY-in-DATA-steps-adding-across-a-single/m-p/122472#M10128</guid>
      <dc:creator>ZachLain</dc:creator>
      <dc:date>2013-02-28T17:14:25Z</dc:date>
    </item>
  </channel>
</rss>

