<?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: substring in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/substring/m-p/833593#M35784</link>
    <description>&lt;P&gt;Either you must review your code yourself and apply the proper logic or supply some example data for us to work with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your code, for example, you have an OR Statement directly after a semicolon. That will produce an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you want something like this, but I'd be guessing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA MYHUMANA.MED_DIAG; 
SET MYHUMANA.MED;
T2D = 0; /**a new variable for type II diabetes**/
ARRAY DIAG (*) ADMISSION_DIAGNOSIS_CODE MEDICAL_PRIMARY_DIAGNOSIS_CODE MEDICAL_DIAGNOSIS_CODE_2 - MEDICAL_DIAGNOSIS_CODE_9;
DO I = 1 TO 10;
IF SUBSTR (DIAG(I),1,3) IN ('250') AND SUBSTR(DX1(I),4,2) NOT IN ('03', '11', '13', '21', '23', '31', '33', '41', '43', '51', '53', '61', '63', '71', '73', '81', '83', '91', '93') THEN T2D = 0; 
IF SUBSTR (DIAG(I),1,3) IN ('E11')then T1D = 1; 
LABEL T2D ='Type II Diabetes';   
END;
RUN;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2022 13:51:31 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2022-09-15T13:51:31Z</dc:date>
    <item>
      <title>substring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/substring/m-p/833579#M35783</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please, I want to get patients with type II diabetes by subtracting those with Type I diabetes from the total patients with diabetes (the general code for diabetes is 250 but sub-types are identified by the last 2 digits). I am doing this because the coding for type I is more correct than type 2 and I was instructed to do so. My code doesn't work probably because I&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA MYHUMANA.MED_DIAG; 
SET MYHUMANA.MED;
T2D = 0; /**a new variable for type II diabetes**/
ARRAY DIAG (*) ADMISSION_DIAGNOSIS_CODE MEDICAL_PRIMARY_DIAGNOSIS_CODE MEDICAL_DIAGNOSIS_CODE_2 - MEDICAL_DIAGNOSIS_CODE_9;
DO I = 1 TO 10;
IF SUBSTR (DIAG(I),1,3) IN ('250') AND SUBSTR NE (DX1(I),4,2)IN ('03', '11', '13', '21', '23', '31', '33', '41', '43', '51', '53', '61', '63', '71', '73', '81', '83', '91', '93') THEN T2D = 0; /**the codes in the DX1(I),4,2 function are type I diabetes**/
OR SUBSTR (DIAG(I),1,3) IN ('E11')then T1D = 1; 
LABEL T2D ='Type II Diabetes';   
END;
RUN; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can't use the NE function with substr. Please advice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 12:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/substring/m-p/833579#M35783</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-09-15T12:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: substring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/substring/m-p/833593#M35784</link>
      <description>&lt;P&gt;Either you must review your code yourself and apply the proper logic or supply some example data for us to work with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your code, for example, you have an OR Statement directly after a semicolon. That will produce an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you want something like this, but I'd be guessing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA MYHUMANA.MED_DIAG; 
SET MYHUMANA.MED;
T2D = 0; /**a new variable for type II diabetes**/
ARRAY DIAG (*) ADMISSION_DIAGNOSIS_CODE MEDICAL_PRIMARY_DIAGNOSIS_CODE MEDICAL_DIAGNOSIS_CODE_2 - MEDICAL_DIAGNOSIS_CODE_9;
DO I = 1 TO 10;
IF SUBSTR (DIAG(I),1,3) IN ('250') AND SUBSTR(DX1(I),4,2) NOT IN ('03', '11', '13', '21', '23', '31', '33', '41', '43', '51', '53', '61', '63', '71', '73', '81', '83', '91', '93') THEN T2D = 0; 
IF SUBSTR (DIAG(I),1,3) IN ('E11')then T1D = 1; 
LABEL T2D ='Type II Diabetes';   
END;
RUN;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 13:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/substring/m-p/833593#M35784</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-15T13:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: substring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/substring/m-p/833731#M35801</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA MYHUMANA.MED_DIAGX; 
SET MYHUMANA.MED;
T2D = 0; /**a new variable for type II diabetes**/
ARRAY DIAG (*) ADMISSION_DIAGNOSIS_CODE MEDICAL_PRIMARY_DIAGNOSIS_CODE MEDICAL_DIAGNOSIS_CODE_2 - MEDICAL_DIAGNOSIS_CODE_9;
DO I = 1 TO 10;
IF SUBSTR (DIAG(I),1,3) IN ('250') AND SUBSTR(DIAG(I),4,2) 
NOT IN ('03', '11', '13', '21', '23', '31', '33', '41', '43', '51', '53', '61', '63', '71', '73', '81', '83', '91', '93') OR 
SUBSTR (DIAG(I),1,3) IN ('E11')then T2D = 1; 
LABEL T2D ='Type II Diabetes';   
END;
RUN; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you so much, the "NOT IN" function was what i was looking for, thnks for spotting the error in my code too. I adjusted my code and it worked&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 20:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/substring/m-p/833731#M35801</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-09-15T20:40:44Z</dc:date>
    </item>
  </channel>
</rss>

