<?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: Type 2 diabetes only by using ICD 9 AN D10 CODES in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Type-2-diabetes-only-by-using-ICD-9-AN-D10-CODES/m-p/833497#M35779</link>
    <description>&lt;P&gt;First a sort of admin bit. Pasting code into a text/code box opened on the forum with the &amp;lt;/&amp;gt; that appears above the message will preserve formatting such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Array;
   set MED;
   array d(9)$ MEDICAL_PRIMARY_DIAGNOSIS_CODE MEDICAL_DIAGNOSIS_CODE_2-MEDICAL_DIAGNOSIS_CODE_9;
   do i=1 to 9;
      DM=0;
      DM1=0; 
      DM2=0;
      if substr (d(i),1,3) = 'E11' then DM1=1;
      if substr (d(i),1,3) = '250' then DM2=1;
      if DM1=1 or DM2=1 then DM=1;
      else DM=0;
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;If you use any indenting in the code to make it easier to follow, as shown, then the code box preserves that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your logic above fails in what I think you may have attempted because the result of the DO loop is always the result for the last variable in the array.&lt;/P&gt;
&lt;P&gt;You can quit a loop on a condition, such as possibly the first time DM=1 by using the LEAVE instruction. Perhaps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Array;
   set MED;
   array d(9)$ MEDICAL_PRIMARY_DIAGNOSIS_CODE MEDICAL_DIAGNOSIS_CODE_2-MEDICAL_DIAGNOSIS_CODE_9;
   do i=1 to 9;
      DM=0;
      DM1=0; 
      DM2=0;
      if substr (d(i),1,3) = 'E11' then DM1=1;
      if substr (d(i),1,3) = '250' then DM2=1;
      if DM1=1 or DM2=1 then do;
           DM=1;
           leave;
      end;
      else DM=0;
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;Or do not keep resetting DM to 0. Only set it to 1 when you want. SAS does not require initializing variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would have to show the entire data step where you attempted to use the IN operator to see but I suspect the exact same issue as above with having your DM set from the last variable in the array, which I also suspect is often missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note if you get tired of&lt;/P&gt;
&lt;PRE&gt; if substr (d(i),1,3) = 'E11' &lt;/PRE&gt;
&lt;P&gt;the =: operator, not the : immediately after the =, is "begins with" and you could use&lt;/P&gt;
&lt;PRE&gt; if d(i) =: 'E11' &lt;/PRE&gt;
&lt;P&gt;The comparison will only use the number of characters on the right side of the =: so you do not need the explicit Substr call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2022 05:59:13 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-09-15T05:59:13Z</dc:date>
    <item>
      <title>Type 2 diabetes only by using ICD 9 AN D10 CODES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Type-2-diabetes-only-by-using-ICD-9-AN-D10-CODES/m-p/833475#M35778</link>
      <description>&lt;P&gt;Hi everyone&lt;/P&gt;&lt;P&gt;I need to get type 2 diabetes patients from claims data by using ICD 9 AND 10 Codes.&lt;/P&gt;&lt;P&gt;when I ran the following code I got Type 1 diabetes patients as well because ICD9 codes of type 2 and 1 start with 250.&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Array;&lt;BR /&gt;set MED;&lt;BR /&gt;array d(9)$ MEDICAL_PRIMARY_DIAGNOSIS_CODE MEDICAL_DIAGNOSIS_CODE_2-MEDICAL_DIAGNOSIS_CODE_9;&lt;BR /&gt;do i=1 to 9;&lt;BR /&gt;DM=0;&lt;BR /&gt;DM1=0; DM2=0;&lt;BR /&gt;if substr (d(i),1,3) = 'E11' then DM1=1;&lt;BR /&gt;if substr (d(i),1,3) = '250' then DM2=1;&lt;BR /&gt;if DM1=1 or DM2=1 then DM=1;&lt;BR /&gt;else DM=0;&lt;BR /&gt;end;&lt;BR /&gt;drop i;&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For type 1 diabetes I have these icd 9 codes to delete but i incorporate it into the above array code it gave 0 observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if substr (d(i),1,5) IN ('25001', '25003', '25011', '24013', '25021','25023', '25031', '25033', '25041', '25043', '25051','25053', '25061', '25063',&lt;BR /&gt;'25071','25073','25081','25083','25091','25093') THEN DM=1;&lt;BR /&gt;if DM=1 then delete;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please guide&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 02:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Type-2-diabetes-only-by-using-ICD-9-AN-D10-CODES/m-p/833475#M35778</guid>
      <dc:creator>centro_9</dc:creator>
      <dc:date>2022-09-15T02:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Type 2 diabetes only by using ICD 9 AN D10 CODES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Type-2-diabetes-only-by-using-ICD-9-AN-D10-CODES/m-p/833497#M35779</link>
      <description>&lt;P&gt;First a sort of admin bit. Pasting code into a text/code box opened on the forum with the &amp;lt;/&amp;gt; that appears above the message will preserve formatting such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Array;
   set MED;
   array d(9)$ MEDICAL_PRIMARY_DIAGNOSIS_CODE MEDICAL_DIAGNOSIS_CODE_2-MEDICAL_DIAGNOSIS_CODE_9;
   do i=1 to 9;
      DM=0;
      DM1=0; 
      DM2=0;
      if substr (d(i),1,3) = 'E11' then DM1=1;
      if substr (d(i),1,3) = '250' then DM2=1;
      if DM1=1 or DM2=1 then DM=1;
      else DM=0;
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;If you use any indenting in the code to make it easier to follow, as shown, then the code box preserves that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your logic above fails in what I think you may have attempted because the result of the DO loop is always the result for the last variable in the array.&lt;/P&gt;
&lt;P&gt;You can quit a loop on a condition, such as possibly the first time DM=1 by using the LEAVE instruction. Perhaps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Array;
   set MED;
   array d(9)$ MEDICAL_PRIMARY_DIAGNOSIS_CODE MEDICAL_DIAGNOSIS_CODE_2-MEDICAL_DIAGNOSIS_CODE_9;
   do i=1 to 9;
      DM=0;
      DM1=0; 
      DM2=0;
      if substr (d(i),1,3) = 'E11' then DM1=1;
      if substr (d(i),1,3) = '250' then DM2=1;
      if DM1=1 or DM2=1 then do;
           DM=1;
           leave;
      end;
      else DM=0;
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;Or do not keep resetting DM to 0. Only set it to 1 when you want. SAS does not require initializing variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would have to show the entire data step where you attempted to use the IN operator to see but I suspect the exact same issue as above with having your DM set from the last variable in the array, which I also suspect is often missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note if you get tired of&lt;/P&gt;
&lt;PRE&gt; if substr (d(i),1,3) = 'E11' &lt;/PRE&gt;
&lt;P&gt;the =: operator, not the : immediately after the =, is "begins with" and you could use&lt;/P&gt;
&lt;PRE&gt; if d(i) =: 'E11' &lt;/PRE&gt;
&lt;P&gt;The comparison will only use the number of characters on the right side of the =: so you do not need the explicit Substr call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 05:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Type-2-diabetes-only-by-using-ICD-9-AN-D10-CODES/m-p/833497#M35779</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-15T05:59:13Z</dc:date>
    </item>
  </channel>
</rss>

