<?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 subscript out of range in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/607101#M176381</link>
    <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am receiving the error message below regarding an array that I am trying to run. I have also provided my code below that. Specifically, I am trying to create a variable (newvar) indicating whether any diagnosis from a set of diagnoses (&amp;amp;painlist) is within 12 months of any diagnosis from a different set (F12.10, F12.20, ...). Can someone please assist me with resolving this issue? Any feedback would be much appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR: Array subscript out of range at line 196 column 3.&lt;/FONT&gt;&lt;BR /&gt;i=100 last.patient_identifier=0 patient_identifier=10 encounter_identifier=224529039 icd=H90.3&lt;BR /&gt;diagnosis_date=20JAN2016 diagnosis_type_description=FINAL DIAGNOSIS FIRST.patient_identifier=0&lt;BR /&gt;new_var=. m=. n=. dif_day=. yes=. _ERROR_=1 _N_=1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;&lt;BR /&gt;by patient_identifier diagnosis_date;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;190  data want;
191   array _c{99} $ 32 _temporary_;
192   array _n{99} _temporary_;
193   do i=1 by 1 until(last.patient_identifier);
194    set have;
195    by patient_identifier;
196    _c{i}=icd;
197    _n{i}=diagnosis_date;
198   end;
199  new_var=0;
200   do m=1 to i-1;
201     do n=m+1 to i;
202      if _c{n} in
202! ('F12.10','F12.120','F12.121','F12.122','F12.129','F12.150','F12.151','F12.159','F12.180','F12.18
202! 8',
203  'F12.19','F12.20','F12.221','F12.222','F12.229','F12.23','F12.250','F12.251','F12.259','F12.288',
203! 'F12.29','F12.90',
204  'F12.920','F12.921','F12.922','F12.929','F12.93','F12.950','F12.951','F12.959','F12.980','F12.988
204! ','F12.99','304.3',
205  '304.30','304.31','304.32','305.2','305.20','305.21','305.22')
206  and _c{m} in (&amp;amp;painlist)
207  then do;
208       dif_day=_n{n}-_n{m};
209       if dif_day le 365 or dif_day ge 365 then do;new_var=1;yes=1;leave;end;
210      end;
211      if yes then leave;
212     end;
213   end;
214   keep patient_identifier new_var;
215   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 25 Nov 2019 19:39:40 GMT</pubDate>
    <dc:creator>wj2</dc:creator>
    <dc:date>2019-11-25T19:39:40Z</dc:date>
    <item>
      <title>Array subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/607101#M176381</link>
      <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am receiving the error message below regarding an array that I am trying to run. I have also provided my code below that. Specifically, I am trying to create a variable (newvar) indicating whether any diagnosis from a set of diagnoses (&amp;amp;painlist) is within 12 months of any diagnosis from a different set (F12.10, F12.20, ...). Can someone please assist me with resolving this issue? Any feedback would be much appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR: Array subscript out of range at line 196 column 3.&lt;/FONT&gt;&lt;BR /&gt;i=100 last.patient_identifier=0 patient_identifier=10 encounter_identifier=224529039 icd=H90.3&lt;BR /&gt;diagnosis_date=20JAN2016 diagnosis_type_description=FINAL DIAGNOSIS FIRST.patient_identifier=0&lt;BR /&gt;new_var=. m=. n=. dif_day=. yes=. _ERROR_=1 _N_=1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;&lt;BR /&gt;by patient_identifier diagnosis_date;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;190  data want;
191   array _c{99} $ 32 _temporary_;
192   array _n{99} _temporary_;
193   do i=1 by 1 until(last.patient_identifier);
194    set have;
195    by patient_identifier;
196    _c{i}=icd;
197    _n{i}=diagnosis_date;
198   end;
199  new_var=0;
200   do m=1 to i-1;
201     do n=m+1 to i;
202      if _c{n} in
202! ('F12.10','F12.120','F12.121','F12.122','F12.129','F12.150','F12.151','F12.159','F12.180','F12.18
202! 8',
203  'F12.19','F12.20','F12.221','F12.222','F12.229','F12.23','F12.250','F12.251','F12.259','F12.288',
203! 'F12.29','F12.90',
204  'F12.920','F12.921','F12.922','F12.929','F12.93','F12.950','F12.951','F12.959','F12.980','F12.988
204! ','F12.99','304.3',
205  '304.30','304.31','304.32','305.2','305.20','305.21','305.22')
206  and _c{m} in (&amp;amp;painlist)
207  then do;
208       dif_day=_n{n}-_n{m};
209       if dif_day le 365 or dif_day ge 365 then do;new_var=1;yes=1;leave;end;
210      end;
211      if yes then leave;
212     end;
213   end;
214   keep patient_identifier new_var;
215   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Nov 2019 19:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/607101#M176381</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-11-25T19:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Array subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/607107#M176384</link>
      <description>&lt;P&gt;Patient identifier 10 apparently has more than 99 observations in dataset HAVE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the ERROR message in the log, you can observe:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;the error occurred in line 196, where you have _c{I}=idc;&lt;/LI&gt;
&lt;LI&gt;the list of variable values reports I=100&lt;/LI&gt;
&lt;LI&gt;the list of variable values reports patient_id=10.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 25 Nov 2019 19:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/607107#M176384</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-25T19:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Array subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/607325#M176510</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;Ah yes, thank you. Would you be able to suggest how the code might be modified to account for variable numbers of observations for each patient (e.g., patients with &amp;gt;99 observations)?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 13:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/607325#M176510</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-11-26T13:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Array subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/607802#M176759</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115194"&gt;@wj2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;Ah yes, thank you. Would you be able to suggest how the code might be modified to account for variable numbers of observations for each patient (e.g., patients with &amp;gt;99 observations)?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It may help to describe what you are actually attempting. Possibly a small example data set and the desired output.&lt;/P&gt;
&lt;P&gt;You may also want to tell us how the resulting data set is to be used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also tell us if you have access to SAS/IML as the way your are using the nested loops smells sort of like an attempt at matrix use.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 18:42:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/607802#M176759</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-27T18:42:28Z</dc:date>
    </item>
  </channel>
</rss>

