<?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: Defining multiple ICD10 codes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559791#M156380</link>
    <description>&lt;P&gt;Awesome -- thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the code above, I get this output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;diagnosis_code1 diagnosis_code2 diagnosis_code3 diagnosis_code4 diagnosis_code5 diagnosis_code6 diagnosis_code7 PSTD&lt;BR /&gt;F43.10 F43.12 F43.13 F43.9 F43.0 F43.8 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I cannot seem to count the number of times the diagnosis of PTSD was made during each visit (PTSD response for variable diagnosis_code1, diagnosis_code2, etc) for each patient in the dataset from this.&amp;nbsp; Proc freq does not recognize PTSD?&amp;nbsp; How would I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, just to get clarity on exactly what&amp;nbsp;$icd_pst pulls up so that I understand the logic, could you explain further?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2019 21:12:51 GMT</pubDate>
    <dc:creator>jessho</dc:creator>
    <dc:date>2019-05-17T21:12:51Z</dc:date>
    <item>
      <title>Defining multiple ICD10 codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559715#M156350</link>
      <description>&lt;P&gt;I know how to label each diagnosis_code variable at a time.&amp;nbsp; Is there a quick way to do this in one step for all my diagnosis code variables (diagnosis_code1, diagnosis_code2, etc).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, if I wanted to modify the code below to capture all the PTSD diagnosis codes for any of the seven diagnosis code variables (diagnosis_code_1 - diagnosis_code_7), how would you amend the code?&amp;nbsp; I tried to - versus or statements with the other diagnosis code variables but continue to get errors. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc format;&lt;BR /&gt;value $icd_pst&lt;BR /&gt;'F43.10', 'F43.11' = 'PTSD'&lt;BR /&gt;other='No PTSD';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;set WORK.testunder1;&lt;BR /&gt;If Put(diagnosis_code_1,$icd_pst.) = 'PTSD' then PTSD=1; run;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 16:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559715#M156350</guid>
      <dc:creator>jessho</dc:creator>
      <dc:date>2019-05-17T16:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Defining multiple ICD10 codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559719#M156353</link>
      <description>&lt;P&gt;could you try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set WORK.testunder1;
If strip(Put(diagnosis_code_1,$icd_pst.)) = 'PTSD' then PTSD=1; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 May 2019 16:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559719#M156353</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-17T16:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Defining multiple ICD10 codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559722#M156355</link>
      <description>&lt;P&gt;Use arrays to process many variables in the same way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set WORK.testunder1;
array diags {8} diagnosis_code_1 - diagnosis_code_8;
do k = 1 to 8 until (ptsd=1);
   If Put(diags{k}, icd_pst.) = 'PTSD' then PTSD=1;
end;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 May 2019 17:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559722#M156355</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-05-17T17:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Defining multiple ICD10 codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559725#M156356</link>
      <description>&lt;P&gt;If you want a variable that indicates if at least one of a group of variables has a value here is one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc format library=work;
value $icd_pst
'F43.10', 'F43.11' = 'PTSD'
other='No PTSD';
run;

data example;
   infile datalines truncover;
   informat d1 - d7 $8.;
   input d1 -d7;
   array dx d1-d7;
   array temp{7} $ 10 _temporary_ ;
   call missing(of temp(*));
   do i= 1 to dim(dx);
      temp[i]= put(dx[i],$icd_pst.);
   end;
   PSTD = ( whichc('PTSD', of temp[*])&amp;gt;0 );
   drop i;
datalines;
F43.2 F42.1 F15.4
F43.2 F42.1 F15.4 F43.10 F41.4
F43.2
F43.11
;
run;
&lt;/PRE&gt;
&lt;P&gt;The array temp defines variables TEMP1 to TEMP7 to hold the formatted value of diagnosis_code (I'm too lazy to use that long of a variable for example so just used D1 to D7).&lt;/P&gt;
&lt;P&gt;The call missing sets the array to blank values. Otherwise _temporary_ arrays can hold values across records. Then populates with the values.&lt;/P&gt;
&lt;P&gt;The function WHICHC searches for the value of the first parameter, in this case the literal 'PTSD' in the following variables. The "of temp[*] " indicates all of the elements of the Array temp are to be used in the search. The function returns which variable in order a match is found (often useful) . In this case just comparing to see if the result is &amp;gt; 0 , i.e. at least one match was found, is used to set the PTSD flag to 1 when found or 0 otherwise.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To search for the other codes from you other post you would repeat this block of code&lt;/P&gt;
&lt;PRE&gt;   call missing(of temp(*));
   do i= 1 to dim(dx);
      temp[i]= put(dx[i],$icd_pst.);
   end;
   PSTD = ( whichc('PTSD', of temp[*])&amp;gt;0 );
   drop i;
&lt;/PRE&gt;
&lt;P&gt;for the other code replacing the 1) format $icd_pst, 2) the variable PSTD to the other flag, and 3) the value 'PTSD' with the other formatted value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a largish number of these codes to search for you could build separate arrays to handle the 1,2, and 3 elements above and wrap the repeated code in a do loop that uses the size of the arrays holding those three things and replace them with array references.&lt;/P&gt;
&lt;P&gt;An additional change would be to change the put(dx[I],&amp;amp;icd_pst.) to PUTC(dx[I],formatarray[j] ); PUTC will allow having a variable to hold the name of a format but a simple PUT requires the literal text of the variable.&lt;/P&gt;
&lt;P&gt;You could use temporary arrays to hold the format name and the search strings but you the array with the flag variable names wouldn't.&amp;nbsp; This is left as an exercise for the interested reader.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 17:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559725#M156356</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-17T17:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Defining multiple ICD10 codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559791#M156380</link>
      <description>&lt;P&gt;Awesome -- thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the code above, I get this output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;diagnosis_code1 diagnosis_code2 diagnosis_code3 diagnosis_code4 diagnosis_code5 diagnosis_code6 diagnosis_code7 PSTD&lt;BR /&gt;F43.10 F43.12 F43.13 F43.9 F43.0 F43.8 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I cannot seem to count the number of times the diagnosis of PTSD was made during each visit (PTSD response for variable diagnosis_code1, diagnosis_code2, etc) for each patient in the dataset from this.&amp;nbsp; Proc freq does not recognize PTSD?&amp;nbsp; How would I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, just to get clarity on exactly what&amp;nbsp;$icd_pst pulls up so that I understand the logic, could you explain further?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 21:12:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/559791#M156380</guid>
      <dc:creator>jessho</dc:creator>
      <dc:date>2019-05-17T21:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Defining multiple ICD10 codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/560291#M156640</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/169154"&gt;@jessho&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Awesome -- thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run the code above, I get this output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;diagnosis_code1 diagnosis_code2 diagnosis_code3 diagnosis_code4 diagnosis_code5 diagnosis_code6 diagnosis_code7 PSTD&lt;BR /&gt;F43.10 F43.12 F43.13 F43.9 F43.0 F43.8 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I cannot seem to count the number of times the diagnosis of PTSD was made during each visit (PTSD response for variable diagnosis_code1, diagnosis_code2, etc) for each patient in the dataset from this.&amp;nbsp; Proc freq does not recognize PTSD?&amp;nbsp; How would I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, just to get clarity on exactly what&amp;nbsp;$icd_pst pulls up so that I understand the logic, could you explain further?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you are using this code, it only sets the value to 1, so no "count"&lt;/P&gt;
&lt;PRE&gt;data test;
set WORK.testunder1;
array diags {8} diagnosis_code_1 - diagnosis_code_8;
do k = 1 to 8 until (ptsd=1);
   If Put(diags{k}, icd_pst.) = 'PTSD' then PTSD=1;
end;run;&lt;/PRE&gt;
&lt;P&gt;Likely not the best but&lt;/P&gt;
&lt;PRE&gt;data test;
set WORK.testunder1;
array diags {8} diagnosis_code_1 - diagnosis_code_8;
do k = 1 to 8 until (ptsd=1);
   Ptsd= sum(ptsd,Put(diags{k}, icd_pst.) = 'PTSD');
end;run;&lt;/PRE&gt;
&lt;P&gt;Personally I would transpose the data to a long format with a diagnosis id and separate value and use a single format to count all the diagnosis code groups&amp;nbsp;at one time similar to:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $example
'A','B'='Group1'
'C','D','E' = 'Group 2'
other = 'Everything else'
;
run;

data example;
  input pid vid did dv $;
   label pid='Patient'
         vid='Visit number'
         dv= 'Diagnosis group'
   ;
datalines;
1  1  1  A
1  1  2  B
1  1  3  F
1  2  1  F
1  2  2  F
1  2  3  C
1  2  4  B
2  1  1  A
2  1  2  B
2  2  3  F
2  2  1  F
2  3  2  F
2  3  3  C
2  3  4  B
;
run;



proc tabulate data=example;
   class pid vid dv;
   format dv $example.;
   table pid*vid*dv,
         n='Count'
   ;
run;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 22:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-multiple-ICD10-codes/m-p/560291#M156640</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-20T22:02:09Z</dc:date>
    </item>
  </channel>
</rss>

