<?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 array processing in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/535181#M16522</link>
    <description>&lt;P&gt;I have the code below to identify psychiatric diagnoses from a principal diagnosis variable (prindiag). Instead of identifying them as yes or no, I would like to uniquely identify them by sub-category. That is, each of the 15 psychiatric diagnoses would be a different number (e.g., 1, 2, 3, 4, 5 ...). Is this possible to do within the data step?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data ip14aNTA; 
set ip14;
array diagvars {1} prindiag;
psyc_flag=0;
do i=1 to 1;
if diagvars{i} in: ( '295' , '296' ,'297' ,'298' ,'300' ,'301', '302', '306' ,'307', '308' , '309' ,'311', '312', '313', '314') 
and diagvars{i} not in ('30252')
then psyc_flag=1;
end;
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Feb 2019 13:17:52 GMT</pubDate>
    <dc:creator>kfluegge</dc:creator>
    <dc:date>2019-02-13T13:17:52Z</dc:date>
    <item>
      <title>array processing</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/535181#M16522</link>
      <description>&lt;P&gt;I have the code below to identify psychiatric diagnoses from a principal diagnosis variable (prindiag). Instead of identifying them as yes or no, I would like to uniquely identify them by sub-category. That is, each of the 15 psychiatric diagnoses would be a different number (e.g., 1, 2, 3, 4, 5 ...). Is this possible to do within the data step?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data ip14aNTA; 
set ip14;
array diagvars {1} prindiag;
psyc_flag=0;
do i=1 to 1;
if diagvars{i} in: ( '295' , '296' ,'297' ,'298' ,'300' ,'301', '302', '306' ,'307', '308' , '309' ,'311', '312', '313', '314') 
and diagvars{i} not in ('30252')
then psyc_flag=1;
end;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Feb 2019 13:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/535181#M16522</guid>
      <dc:creator>kfluegge</dc:creator>
      <dc:date>2019-02-13T13:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: array processing</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/535183#M16523</link>
      <description>&lt;P&gt;The WHICHC function does this.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0jfvenvsqk24vn1q2ypospoq9ij.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0jfvenvsqk24vn1q2ypospoq9ij.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I don't see is how having numbers 1 through 15 is superior for further analyses, or for reporting, than having the character strings&amp;nbsp;'295' , '296' , &lt;EM&gt;etc&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 13:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/535183#M16523</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-13T13:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: array processing</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/536102#M16533</link>
      <description>&lt;P&gt;It's mildly complicated by the truncation of in: but it can definitely be done.&amp;nbsp; Here's an approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
array temp {999} _temporary_;
if _n_=1 then do subcat = '295', '296', '297', '298', '300', '301', '302', '306',
      '307', '308', '309', '311', '312', '313', '314';
   k + 1;
   temp{k} = k;
end;
set have;
if prindiag not in : ('000', '30252', '   ') then 
psyc_flag = temp{input(prindiag, 3.)};&lt;BR /&gt;drop k subcat;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The top part of the DATA step places the numbers 1 through 15 into matching spots of the temporary array.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The final computations omit diagnoses 30252, blank, and anything that begins with 000.&amp;nbsp; Then it looks up the value 1 through 15 or missing, depending on the value of PRINDIAG.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Feb 2019 00:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/536102#M16533</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-16T00:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: array processing</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/536106#M16534</link>
      <description>&lt;P&gt;Your code doesn't really make much sense.&amp;nbsp; You are looping over&amp;nbsp; the character strings codes but then ignoring them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Were you trying to make a sparse array using the numeric value of the codes as the index?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array temp {0:999} _temporary_;
if _n_=1 then do x = 295 to 298, 300 to 302, 306 to 309, 311 to 314;
   k + 1;
   temp{x} = k;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Feb 2019 01:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/536106#M16534</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-16T01:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: array processing</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/536107#M16535</link>
      <description>Long day ... you're 100% right.  Thanks!</description>
      <pubDate>Sat, 16 Feb 2019 01:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/536107#M16535</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-16T01:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: array processing</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/536142#M16538</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120373"&gt;@kfluegge&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're just after re-coding the values in prindiag then code like below should do (untested as no sample data provided).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value $recodePrindiag (default=2)
    '295' = '01'
    '296' = '02'
    '297' = '03'
    '298' = '04'
    '300' = '05'
    '301' = '06'
    '302' = '07'
    '306' = '08'
    '307' = '09'
    '308' = '10'
    '309' = '11'
    '311' = '12'
    '312' = '13'
    '313' = '14'
    '314' = '15'
    other = '-1'
    ;
run;

data ip14aNTA;
  set ip14;
  prindiag_recoded=put(prindiag,$recodePrindiag.);
  psyc_flag= (prindiag_recoded ne '-1');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Feb 2019 07:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/array-processing/m-p/536142#M16538</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-02-16T07:14:30Z</dc:date>
    </item>
  </channel>
</rss>

