<?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: Find multiple ICD 9/10 codes over multiple diagnosis variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-multiple-ICD-9-10-codes-over-multiple-diagnosis-variables/m-p/428247#M105715</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187182"&gt;@atex&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Please always post sample data in form of a data step and then show us the desired result. This helps us to better understand what you have and also test our code against your sample.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;List-processing is "better" implemented in other languages. Below code does what you're after if I've&amp;nbsp;understood your Stata code correctly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;  
  array diag {25} $10 (25*'other code');
  output;
  diag4='code3';
  diag15='code2';
  output;
run;


proc format;
  invalue diagcode
    'code1'=1
    'code2'=1
    'code3'=1
  ;
run;

data want;
  flag=0;
  set have;
  array diags {*} diag:;
  do _i=1 to dim(diags);
    if input(diags[_i],diagcode.)=1 then
      do;
        flag=1;
        leave;
      end;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jan 2018 20:38:53 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2018-01-17T20:38:53Z</dc:date>
    <item>
      <title>Find multiple ICD 9/10 codes over multiple diagnosis variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-multiple-ICD-9-10-codes-over-multiple-diagnosis-variables/m-p/428243#M105713</link>
      <description>&lt;P&gt;Hi, I am a long time STATA user who is required to use SAS for a certain project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I search for a list of 20 diagnosis codes over 25 diagnosis variables (diag1-diag25) and have it flag a new variable as one?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would be similar to the STATA code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;local diagcode&lt;/P&gt;&lt;P&gt;"xxxxx"&lt;/P&gt;&lt;P&gt;"xxxxx"&lt;/P&gt;&lt;P&gt;"xxxxx"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;foreach x of varlist diag1-diag25 {&lt;/P&gt;&lt;P&gt;replace diabetes = 1 if `x' == diagcode&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 02:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-multiple-ICD-9-10-codes-over-multiple-diagnosis-variables/m-p/428243#M105713</guid>
      <dc:creator>atex</dc:creator>
      <dc:date>2018-01-17T02:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Find multiple ICD 9/10 codes over multiple diagnosis variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-multiple-ICD-9-10-codes-over-multiple-diagnosis-variables/m-p/428247#M105715</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187182"&gt;@atex&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Please always post sample data in form of a data step and then show us the desired result. This helps us to better understand what you have and also test our code against your sample.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;List-processing is "better" implemented in other languages. Below code does what you're after if I've&amp;nbsp;understood your Stata code correctly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;  
  array diag {25} $10 (25*'other code');
  output;
  diag4='code3';
  diag15='code2';
  output;
run;


proc format;
  invalue diagcode
    'code1'=1
    'code2'=1
    'code3'=1
  ;
run;

data want;
  flag=0;
  set have;
  array diags {*} diag:;
  do _i=1 to dim(diags);
    if input(diags[_i],diagcode.)=1 then
      do;
        flag=1;
        leave;
      end;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 20:38:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-multiple-ICD-9-10-codes-over-multiple-diagnosis-variables/m-p/428247#M105715</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-01-17T20:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Find multiple ICD 9/10 codes over multiple diagnosis variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-multiple-ICD-9-10-codes-over-multiple-diagnosis-variables/m-p/428561#M105824</link>
      <description>&lt;P&gt;What does "it flag a new variable as one" actually mean?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHICHN or WHICHC (depending on whether your diagnosis variables and diagnosis codes are numeric or character) may work.&lt;/P&gt;
&lt;P&gt;A brief example of what I think you are doing. Diag holds the diagnosis codes, the array c has the code values you are looking for and the array f has variable that hold flag values of 1 or 0 for found.&lt;/P&gt;
&lt;PRE&gt;data work.example;
   informat diag1 - diag3 $2.;
   input diag1 - diag3 ;
   array d diag: ;
   /* this holds the values of the codes to search for*/
   array c (4) $ 2 _temporary_ ('Ab','Ac','Ba','Bb');
   /* and results size should match array c*/
   array f Ab Ac Ba Bb;
   do i=1 to dim(c);
      f[i]=whichc(c[i],of d(*))&amp;gt;0;
   end;

datalines;
Ab Ac Ad
Ac Ac Ae
Ba Bb Bc
Bb Bb Bb
;
   
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jan 2018 19:21:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-multiple-ICD-9-10-codes-over-multiple-diagnosis-variables/m-p/428561#M105824</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-17T19:21:04Z</dc:date>
    </item>
  </channel>
</rss>

