<?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: Array subscript out of range in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418209#M102722</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;drug_index=120 &lt;STRONG&gt;end_index=121&lt;/STRONG&gt; cov_ab_12=1 &lt;STRONG&gt;j=121&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;The above is the last bit from your log. Note the values of end_index and J, 121&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your logic is flawed somehow, and since I can't follow it, I can't say how.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you have and what do you want? It would likely be easier to use SAS dates and date calculations instead of what you're trying here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;LI-SPOILER&gt;priya1286 wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Reeza!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the full log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Array subscript out of range at line 1521 column 8.&lt;BR /&gt;bene_id=eeeeee119EAh1rJ srvc_dt=12/22/2015 end_dt=01/20/2016 dayssply=30 drg_name=slz BUYIN01=&lt;BR /&gt;BUYIN02= BUYIN03= BUYIN04= BUYIN05= BUYIN06= BUYIN07= BUYIN08= BUYIN09= BUYIN10=&lt;BR /&gt;BUYIN11= BUYIN12= HMOIND01= HMOIND02= HMOIND03= HMOIND04= HMOIND05= HMOIND06= HMOIND07=&lt;BR /&gt;HMOIND08= HMOIND09= HMOIND10= HMOIND11= HMOIND12= CNTRCT01= CNTRCT02= CNTRCT03= CNTRCT04=&lt;BR /&gt;CNTRCT05= CNTRCT06= CNTRCT07= CNTRCT08= CNTRCT09= CNTRCT10= CNTRCT11= CNTRCT12= buyin13=&lt;BR /&gt;buyin14= buyin15= buyin16= buyin17= buyin18= buyin19= buyin20= buyin21= buyin22=&lt;BR /&gt;buyin23= buyin24= hmoind13= hmoind14= hmoind15= hmoind16= hmoind17= hmoind18= hmoind19=&lt;BR /&gt;hmoind20= hmoind21= hmoind22= hmoind23= hmoind24= cntrct13= cntrct14= cntrct15= cntrct16=&lt;BR /&gt;cntrct17= cntrct18= cntrct19= cntrct20= cntrct21= cntrct22= cntrct23= cntrct24= buyin25=&lt;BR /&gt;buyin26= buyin27= buyin28= buyin29= buyin30= buyin31= buyin32= buyin33= buyin34=&lt;BR /&gt;buyin35= buyin36= hmoind25= hmoind26= hmoind27= hmoind28= hmoind29= hmoind30= hmoind31=&lt;BR /&gt;hmoind32= hmoind33= hmoind34= hmoind35= hmoind36= cntrct25= cntrct26= cntrct27= cntrct28=&lt;BR /&gt;cntrct29= cntrct30= cntrct31= cntrct32= cntrct33= cntrct34= cntrct35= cntrct36= buyin97=C&lt;BR /&gt;buyin98=C buyin99=C buyin100=C buyin101=C buyin102=C buyin103=C buyin104=C buyin105=C buyin106=C&lt;BR /&gt;buyin107=C buyin108=C hmoind97=0 hmoind98=0 hmoind99=0 hmoind100=0 hmoind101=0 hmoind102=0&lt;BR /&gt;hmoind103=0 hmoind104=0 hmoind105=0 hmoind106=0 hmoind107=0 hmoind108=0 cntrct97=S5921&lt;BR /&gt;cntrct98=S5921 cntrct99=S5921 cntrct100=S5921 cntrct101=S5921 cntrct102=S5921 cntrct103=S5921&lt;BR /&gt;cntrct104=S5921 cntrct105=S5921 cntrct106=S5921 cntrct107=S5921 cntrct108=S5921 buyin109=C&lt;BR /&gt;buyin110=C buyin111=C buyin112=C buyin113=C buyin114=C buyin115=C buyin116=C buyin117=C buyin118=C&lt;BR /&gt;buyin119=C buyin120=C hmoind109=0 hmoind110=0 hmoind111=0 hmoind112=0 hmoind113=0 hmoind114=0&lt;BR /&gt;hmoind115=0 hmoind116=0 hmoind117=0 hmoind118=0 hmoind119=0 hmoind120=0 cntrct109=S5921&lt;BR /&gt;cntrct110=S5921 cntrct111=S5921 cntrct112=S5921 cntrct113=S5921 cntrct114=S5921 cntrct115=S5921&lt;BR /&gt;cntrct116=S5921 cntrct117=S5921 cntrct118=S5921 cntrct119=S5921 cntrct120=S5921 buyin37=&lt;BR /&gt;buyin38= buyin39= buyin40= buyin41= buyin42= buyin43= buyin44= buyin45= buyin46=&lt;BR /&gt;buyin47= buyin48= hmoind37= hmoind38= hmoind39= hmoind40= hmoind41= hmoind42= hmoind43=&lt;BR /&gt;hmoind44= hmoind45= hmoind46= hmoind47= hmoind48= buyin49= buyin50= buyin51= buyin52=&lt;BR /&gt;buyin53= buyin54= buyin55= buyin56= buyin57= buyin58= buyin59= buyin60= hmoind49=&lt;BR /&gt;hmoind50= hmoind51= hmoind52= hmoind53= hmoind54= hmoind55= hmoind56= hmoind57= hmoind58=&lt;BR /&gt;hmoind59= hmoind60= buyin61= buyin62= buyin63= buyin64= buyin65= buyin66= buyin67=&lt;BR /&gt;buyin68= buyin69= buyin70= buyin71= buyin72= hmoind61= hmoind62= hmoind63= hmoind64=&lt;BR /&gt;hmoind65= hmoind66= hmoind67= hmoind68= hmoind69= hmoind70= hmoind71= hmoind72= buyin73=&lt;BR /&gt;buyin74= buyin75= buyin76= buyin77= buyin78= buyin79= buyin80= buyin81= buyin82=&lt;BR /&gt;buyin83= buyin84= hmoind73= hmoind74= hmoind75= hmoind76= hmoind77= hmoind78= hmoind79=&lt;BR /&gt;hmoind80= hmoind81= hmoind82= hmoind83= hmoind84= buyin85=0 buyin86=0 buyin87=0 buyin88=0&lt;BR /&gt;buyin89=0 buyin90=0 buyin91=C buyin92=C buyin93=C buyin94=C buyin95=C buyin96=C hmoind85=0&lt;BR /&gt;hmoind86=0 hmoind87=0 hmoind88=0 hmoind89=0 hmoind90=0 hmoind91=0 hmoind92=0 hmoind93=0 hmoind94=0&lt;BR /&gt;hmoind95=0 hmoind96=0 cntrct37= cntrct38= cntrct39= cntrct40= cntrct41= cntrct42= cntrct43=&lt;BR /&gt;cntrct44= cntrct45= cntrct46= cntrct47= cntrct48= cntrct49= cntrct50= cntrct51= cntrct52=&lt;BR /&gt;cntrct53= cntrct54= cntrct55= cntrct56= cntrct57= cntrct58= cntrct59= cntrct60= cntrct61=&lt;BR /&gt;cntrct62= cntrct63= cntrct64= cntrct65= cntrct66= cntrct67= cntrct68= cntrct69= cntrct70=&lt;BR /&gt;cntrct71= cntrct72= cntrct73= cntrct74= cntrct75= cntrct76= cntrct77= cntrct78= cntrct79=&lt;BR /&gt;cntrct80= cntrct81= cntrct82= cntrct83= cntrct84= cntrct85=0 cntrct86=0 cntrct87=0 cntrct88=0&lt;BR /&gt;cntrct89=0 cntrct90=0 cntrct91=N cntrct92=N cntrct93=N cntrct94=X0001 cntrct95=X0001&lt;BR /&gt;cntrct96=S5921 count=3 end_f=01/02/2016 drug_index=120 end_index=121 cov_ab_12=1 j=121 cov_d_12=.&lt;BR /&gt;&amp;nbsp;_ERROR_=1 _N_=37&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The drug_index and end_index variables weren't supposed to to act as dates. They are calculated as numbers to indicate the nth day when the drug was taken. What is confusing is that I didn't get this error when I did "do j = (drug_index - g) to end_index.&lt;/P&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Dec 2017 16:20:06 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-12-04T16:20:06Z</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/418203#M102717</link>
      <description>&lt;P&gt;Here is my program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1472 data first_use4;&lt;BR /&gt;1473 set wkspace.first_use3;&lt;BR /&gt;1474 end_f = srvc_dt+11;&lt;BR /&gt;1475 format end_f mmddyy10.;&lt;BR /&gt;1476 array months_12 (120) $ buyin01 - buyin120;&lt;BR /&gt;1477 drug_index = month(srvc_dt) + (12 * (year(srvc_dt) - 2006));&lt;BR /&gt;1478 end_index = month(end_f) + (12 * (year(end_f)- 2006));/*This will ensure at least 12&lt;BR /&gt;1478! months of follow-up*/&lt;BR /&gt;1479 cov_ab_12=1;&lt;BR /&gt;1480 do j = (drug_index - 12) to end_index;&lt;BR /&gt;1481 if months_12 {j} in ("0","1","2","A","B") then do;&lt;BR /&gt;1482 cov_ab_12=0; /* exclude the current patient */&lt;BR /&gt;1483 leave; /* break out of the DO loop */&lt;BR /&gt;1484 end;&lt;BR /&gt;1485 end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the following error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Array subscript out of range at line 1481 column 8.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran the same program successfully a day ago and now I am getting this error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed the following statements:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1480 do j = (drug_index - 12) to end_index;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;/* (previously) do j=(drug_index-6) to end_index;*/&lt;BR /&gt;&lt;SPAN&gt;1481 if months_12 {j} in ("0","1","2","A","B") then do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/* (previously) if months_12 {j} not in ("3","C");*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any input will be very helpful.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 15:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418203#M102717</guid>
      <dc:creator>priya1286</dc:creator>
      <dc:date>2017-12-04T15:59:05Z</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/418205#M102718</link>
      <description>&lt;P&gt;The log will also tell you what J was at that record, can you include the full log?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I doubt your loop is doing what you think because it's a number (not a SAS date though) and you can't subtract them to get duration.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 16:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418205#M102718</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-04T16:01: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/418207#M102720</link>
      <description>&lt;P&gt;Thanks Reeza!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the full log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Array subscript out of range at line 1521 column 8.&lt;BR /&gt;bene_id=eeeeee119EAh1rJ srvc_dt=12/22/2015 end_dt=01/20/2016 dayssply=30 drg_name=slz BUYIN01=&lt;BR /&gt;BUYIN02= BUYIN03= BUYIN04= BUYIN05= BUYIN06= BUYIN07= BUYIN08= BUYIN09= BUYIN10=&lt;BR /&gt;BUYIN11= BUYIN12= HMOIND01= HMOIND02= HMOIND03= HMOIND04= HMOIND05= HMOIND06= HMOIND07=&lt;BR /&gt;HMOIND08= HMOIND09= HMOIND10= HMOIND11= HMOIND12= CNTRCT01= CNTRCT02= CNTRCT03= CNTRCT04=&lt;BR /&gt;CNTRCT05= CNTRCT06= CNTRCT07= CNTRCT08= CNTRCT09= CNTRCT10= CNTRCT11= CNTRCT12= buyin13=&lt;BR /&gt;buyin14= buyin15= buyin16= buyin17= buyin18= buyin19= buyin20= buyin21= buyin22=&lt;BR /&gt;buyin23= buyin24= hmoind13= hmoind14= hmoind15= hmoind16= hmoind17= hmoind18= hmoind19=&lt;BR /&gt;hmoind20= hmoind21= hmoind22= hmoind23= hmoind24= cntrct13= cntrct14= cntrct15= cntrct16=&lt;BR /&gt;cntrct17= cntrct18= cntrct19= cntrct20= cntrct21= cntrct22= cntrct23= cntrct24= buyin25=&lt;BR /&gt;buyin26= buyin27= buyin28= buyin29= buyin30= buyin31= buyin32= buyin33= buyin34=&lt;BR /&gt;buyin35= buyin36= hmoind25= hmoind26= hmoind27= hmoind28= hmoind29= hmoind30= hmoind31=&lt;BR /&gt;hmoind32= hmoind33= hmoind34= hmoind35= hmoind36= cntrct25= cntrct26= cntrct27= cntrct28=&lt;BR /&gt;cntrct29= cntrct30= cntrct31= cntrct32= cntrct33= cntrct34= cntrct35= cntrct36= buyin97=C&lt;BR /&gt;buyin98=C buyin99=C buyin100=C buyin101=C buyin102=C buyin103=C buyin104=C buyin105=C buyin106=C&lt;BR /&gt;buyin107=C buyin108=C hmoind97=0 hmoind98=0 hmoind99=0 hmoind100=0 hmoind101=0 hmoind102=0&lt;BR /&gt;hmoind103=0 hmoind104=0 hmoind105=0 hmoind106=0 hmoind107=0 hmoind108=0 cntrct97=S5921&lt;BR /&gt;cntrct98=S5921 cntrct99=S5921 cntrct100=S5921 cntrct101=S5921 cntrct102=S5921 cntrct103=S5921&lt;BR /&gt;cntrct104=S5921 cntrct105=S5921 cntrct106=S5921 cntrct107=S5921 cntrct108=S5921 buyin109=C&lt;BR /&gt;buyin110=C buyin111=C buyin112=C buyin113=C buyin114=C buyin115=C buyin116=C buyin117=C buyin118=C&lt;BR /&gt;buyin119=C buyin120=C hmoind109=0 hmoind110=0 hmoind111=0 hmoind112=0 hmoind113=0 hmoind114=0&lt;BR /&gt;hmoind115=0 hmoind116=0 hmoind117=0 hmoind118=0 hmoind119=0 hmoind120=0 cntrct109=S5921&lt;BR /&gt;cntrct110=S5921 cntrct111=S5921 cntrct112=S5921 cntrct113=S5921 cntrct114=S5921 cntrct115=S5921&lt;BR /&gt;cntrct116=S5921 cntrct117=S5921 cntrct118=S5921 cntrct119=S5921 cntrct120=S5921 buyin37=&lt;BR /&gt;buyin38= buyin39= buyin40= buyin41= buyin42= buyin43= buyin44= buyin45= buyin46=&lt;BR /&gt;buyin47= buyin48= hmoind37= hmoind38= hmoind39= hmoind40= hmoind41= hmoind42= hmoind43=&lt;BR /&gt;hmoind44= hmoind45= hmoind46= hmoind47= hmoind48= buyin49= buyin50= buyin51= buyin52=&lt;BR /&gt;buyin53= buyin54= buyin55= buyin56= buyin57= buyin58= buyin59= buyin60= hmoind49=&lt;BR /&gt;hmoind50= hmoind51= hmoind52= hmoind53= hmoind54= hmoind55= hmoind56= hmoind57= hmoind58=&lt;BR /&gt;hmoind59= hmoind60= buyin61= buyin62= buyin63= buyin64= buyin65= buyin66= buyin67=&lt;BR /&gt;buyin68= buyin69= buyin70= buyin71= buyin72= hmoind61= hmoind62= hmoind63= hmoind64=&lt;BR /&gt;hmoind65= hmoind66= hmoind67= hmoind68= hmoind69= hmoind70= hmoind71= hmoind72= buyin73=&lt;BR /&gt;buyin74= buyin75= buyin76= buyin77= buyin78= buyin79= buyin80= buyin81= buyin82=&lt;BR /&gt;buyin83= buyin84= hmoind73= hmoind74= hmoind75= hmoind76= hmoind77= hmoind78= hmoind79=&lt;BR /&gt;hmoind80= hmoind81= hmoind82= hmoind83= hmoind84= buyin85=0 buyin86=0 buyin87=0 buyin88=0&lt;BR /&gt;buyin89=0 buyin90=0 buyin91=C buyin92=C buyin93=C buyin94=C buyin95=C buyin96=C hmoind85=0&lt;BR /&gt;hmoind86=0 hmoind87=0 hmoind88=0 hmoind89=0 hmoind90=0 hmoind91=0 hmoind92=0 hmoind93=0 hmoind94=0&lt;BR /&gt;hmoind95=0 hmoind96=0 cntrct37= cntrct38= cntrct39= cntrct40= cntrct41= cntrct42= cntrct43=&lt;BR /&gt;cntrct44= cntrct45= cntrct46= cntrct47= cntrct48= cntrct49= cntrct50= cntrct51= cntrct52=&lt;BR /&gt;cntrct53= cntrct54= cntrct55= cntrct56= cntrct57= cntrct58= cntrct59= cntrct60= cntrct61=&lt;BR /&gt;cntrct62= cntrct63= cntrct64= cntrct65= cntrct66= cntrct67= cntrct68= cntrct69= cntrct70=&lt;BR /&gt;cntrct71= cntrct72= cntrct73= cntrct74= cntrct75= cntrct76= cntrct77= cntrct78= cntrct79=&lt;BR /&gt;cntrct80= cntrct81= cntrct82= cntrct83= cntrct84= cntrct85=0 cntrct86=0 cntrct87=0 cntrct88=0&lt;BR /&gt;cntrct89=0 cntrct90=0 cntrct91=N cntrct92=N cntrct93=N cntrct94=X0001 cntrct95=X0001&lt;BR /&gt;cntrct96=S5921 count=3 end_f=01/02/2016 drug_index=120 end_index=121 cov_ab_12=1 j=121 cov_d_12=.&lt;BR /&gt;&amp;nbsp;_ERROR_=1 _N_=37&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The drug_index and end_index variables weren't supposed to to act as dates. They are calculated as numbers to indicate the nth day when the drug was taken. What is confusing is that I didn't get this error when I did "do j = (drug_index - g) to end_index.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 16:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418207#M102720</guid>
      <dc:creator>priya1286</dc:creator>
      <dc:date>2017-12-04T16:14:37Z</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/418209#M102722</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;drug_index=120 &lt;STRONG&gt;end_index=121&lt;/STRONG&gt; cov_ab_12=1 &lt;STRONG&gt;j=121&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;The above is the last bit from your log. Note the values of end_index and J, 121&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your logic is flawed somehow, and since I can't follow it, I can't say how.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you have and what do you want? It would likely be easier to use SAS dates and date calculations instead of what you're trying here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;LI-SPOILER&gt;priya1286 wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Reeza!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the full log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Array subscript out of range at line 1521 column 8.&lt;BR /&gt;bene_id=eeeeee119EAh1rJ srvc_dt=12/22/2015 end_dt=01/20/2016 dayssply=30 drg_name=slz BUYIN01=&lt;BR /&gt;BUYIN02= BUYIN03= BUYIN04= BUYIN05= BUYIN06= BUYIN07= BUYIN08= BUYIN09= BUYIN10=&lt;BR /&gt;BUYIN11= BUYIN12= HMOIND01= HMOIND02= HMOIND03= HMOIND04= HMOIND05= HMOIND06= HMOIND07=&lt;BR /&gt;HMOIND08= HMOIND09= HMOIND10= HMOIND11= HMOIND12= CNTRCT01= CNTRCT02= CNTRCT03= CNTRCT04=&lt;BR /&gt;CNTRCT05= CNTRCT06= CNTRCT07= CNTRCT08= CNTRCT09= CNTRCT10= CNTRCT11= CNTRCT12= buyin13=&lt;BR /&gt;buyin14= buyin15= buyin16= buyin17= buyin18= buyin19= buyin20= buyin21= buyin22=&lt;BR /&gt;buyin23= buyin24= hmoind13= hmoind14= hmoind15= hmoind16= hmoind17= hmoind18= hmoind19=&lt;BR /&gt;hmoind20= hmoind21= hmoind22= hmoind23= hmoind24= cntrct13= cntrct14= cntrct15= cntrct16=&lt;BR /&gt;cntrct17= cntrct18= cntrct19= cntrct20= cntrct21= cntrct22= cntrct23= cntrct24= buyin25=&lt;BR /&gt;buyin26= buyin27= buyin28= buyin29= buyin30= buyin31= buyin32= buyin33= buyin34=&lt;BR /&gt;buyin35= buyin36= hmoind25= hmoind26= hmoind27= hmoind28= hmoind29= hmoind30= hmoind31=&lt;BR /&gt;hmoind32= hmoind33= hmoind34= hmoind35= hmoind36= cntrct25= cntrct26= cntrct27= cntrct28=&lt;BR /&gt;cntrct29= cntrct30= cntrct31= cntrct32= cntrct33= cntrct34= cntrct35= cntrct36= buyin97=C&lt;BR /&gt;buyin98=C buyin99=C buyin100=C buyin101=C buyin102=C buyin103=C buyin104=C buyin105=C buyin106=C&lt;BR /&gt;buyin107=C buyin108=C hmoind97=0 hmoind98=0 hmoind99=0 hmoind100=0 hmoind101=0 hmoind102=0&lt;BR /&gt;hmoind103=0 hmoind104=0 hmoind105=0 hmoind106=0 hmoind107=0 hmoind108=0 cntrct97=S5921&lt;BR /&gt;cntrct98=S5921 cntrct99=S5921 cntrct100=S5921 cntrct101=S5921 cntrct102=S5921 cntrct103=S5921&lt;BR /&gt;cntrct104=S5921 cntrct105=S5921 cntrct106=S5921 cntrct107=S5921 cntrct108=S5921 buyin109=C&lt;BR /&gt;buyin110=C buyin111=C buyin112=C buyin113=C buyin114=C buyin115=C buyin116=C buyin117=C buyin118=C&lt;BR /&gt;buyin119=C buyin120=C hmoind109=0 hmoind110=0 hmoind111=0 hmoind112=0 hmoind113=0 hmoind114=0&lt;BR /&gt;hmoind115=0 hmoind116=0 hmoind117=0 hmoind118=0 hmoind119=0 hmoind120=0 cntrct109=S5921&lt;BR /&gt;cntrct110=S5921 cntrct111=S5921 cntrct112=S5921 cntrct113=S5921 cntrct114=S5921 cntrct115=S5921&lt;BR /&gt;cntrct116=S5921 cntrct117=S5921 cntrct118=S5921 cntrct119=S5921 cntrct120=S5921 buyin37=&lt;BR /&gt;buyin38= buyin39= buyin40= buyin41= buyin42= buyin43= buyin44= buyin45= buyin46=&lt;BR /&gt;buyin47= buyin48= hmoind37= hmoind38= hmoind39= hmoind40= hmoind41= hmoind42= hmoind43=&lt;BR /&gt;hmoind44= hmoind45= hmoind46= hmoind47= hmoind48= buyin49= buyin50= buyin51= buyin52=&lt;BR /&gt;buyin53= buyin54= buyin55= buyin56= buyin57= buyin58= buyin59= buyin60= hmoind49=&lt;BR /&gt;hmoind50= hmoind51= hmoind52= hmoind53= hmoind54= hmoind55= hmoind56= hmoind57= hmoind58=&lt;BR /&gt;hmoind59= hmoind60= buyin61= buyin62= buyin63= buyin64= buyin65= buyin66= buyin67=&lt;BR /&gt;buyin68= buyin69= buyin70= buyin71= buyin72= hmoind61= hmoind62= hmoind63= hmoind64=&lt;BR /&gt;hmoind65= hmoind66= hmoind67= hmoind68= hmoind69= hmoind70= hmoind71= hmoind72= buyin73=&lt;BR /&gt;buyin74= buyin75= buyin76= buyin77= buyin78= buyin79= buyin80= buyin81= buyin82=&lt;BR /&gt;buyin83= buyin84= hmoind73= hmoind74= hmoind75= hmoind76= hmoind77= hmoind78= hmoind79=&lt;BR /&gt;hmoind80= hmoind81= hmoind82= hmoind83= hmoind84= buyin85=0 buyin86=0 buyin87=0 buyin88=0&lt;BR /&gt;buyin89=0 buyin90=0 buyin91=C buyin92=C buyin93=C buyin94=C buyin95=C buyin96=C hmoind85=0&lt;BR /&gt;hmoind86=0 hmoind87=0 hmoind88=0 hmoind89=0 hmoind90=0 hmoind91=0 hmoind92=0 hmoind93=0 hmoind94=0&lt;BR /&gt;hmoind95=0 hmoind96=0 cntrct37= cntrct38= cntrct39= cntrct40= cntrct41= cntrct42= cntrct43=&lt;BR /&gt;cntrct44= cntrct45= cntrct46= cntrct47= cntrct48= cntrct49= cntrct50= cntrct51= cntrct52=&lt;BR /&gt;cntrct53= cntrct54= cntrct55= cntrct56= cntrct57= cntrct58= cntrct59= cntrct60= cntrct61=&lt;BR /&gt;cntrct62= cntrct63= cntrct64= cntrct65= cntrct66= cntrct67= cntrct68= cntrct69= cntrct70=&lt;BR /&gt;cntrct71= cntrct72= cntrct73= cntrct74= cntrct75= cntrct76= cntrct77= cntrct78= cntrct79=&lt;BR /&gt;cntrct80= cntrct81= cntrct82= cntrct83= cntrct84= cntrct85=0 cntrct86=0 cntrct87=0 cntrct88=0&lt;BR /&gt;cntrct89=0 cntrct90=0 cntrct91=N cntrct92=N cntrct93=N cntrct94=X0001 cntrct95=X0001&lt;BR /&gt;cntrct96=S5921 count=3 end_f=01/02/2016 drug_index=120 end_index=121 cov_ab_12=1 j=121 cov_d_12=.&lt;BR /&gt;&amp;nbsp;_ERROR_=1 _N_=37&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The drug_index and end_index variables weren't supposed to to act as dates. They are calculated as numbers to indicate the nth day when the drug was taken. What is confusing is that I didn't get this error when I did "do j = (drug_index - g) to end_index.&lt;/P&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 16:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418209#M102722</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-04T16:20:06Z</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/418212#M102723</link>
      <description>&lt;P&gt;Your line&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;end_f = srvc_dt+&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;11&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;is incrementing the date by 11 days. I think you intend 11 months from usage.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;Also andy service date prior to 1/1/2007 would have the starting J index value (drug_index-12)&amp;nbsp;as 0 or smaller; 1/1/2017 would have the value &amp;gt; 120.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;Having an uncommented magic number like 2006 in your code can lead to maintenance issues. Such as did this code run previously where the data only consisted of values from 2007 to 2016 but now needs an adjustment to handle 2017 (as possibly a start of a different year?)&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 16:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418212#M102723</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-04T16:30:48Z</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/418259#M102739</link>
      <description>Thanks for your input! The problem was end_dt going beyond the value 120.&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Dec 2017 18:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418259#M102739</guid>
      <dc:creator>priya1286</dc:creator>
      <dc:date>2017-12-04T18:49:13Z</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/418261#M102741</link>
      <description>&lt;P&gt;has it worked?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 18:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418261#M102741</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-12-04T18:57:24Z</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/418262#M102742</link>
      <description>Yes it did! the problem was end_f being more than the data years that I have.&lt;BR /&gt;Here is the modified code:&lt;BR /&gt;data first_use4;&lt;BR /&gt;set wkspace.first_use3;&lt;BR /&gt;end_f = srvc_dt+365;&lt;BR /&gt;format end_f mmddyy10.;&lt;BR /&gt;if end_f &amp;gt; mdy(12,31,2015) then end_f = mdy(12,31,2015);&lt;BR /&gt;&lt;BR /&gt;array months_12 (*) $ buyin01 - buyin120;&lt;BR /&gt;drug_index = month(srvc_dt) + (12 * (year(srvc_dt) - 2006));&lt;BR /&gt;end_index = month(end_f) + (12 * (year(end_f)- 2006));/*This will ensure at least 12 months of follow-up*/&lt;BR /&gt;&lt;BR /&gt;cov_ab_12=1;&lt;BR /&gt;do j = (drug_index - 12) to end_index;&lt;BR /&gt;if months_12 {j} not in ("3","C") then do;&lt;BR /&gt;cov_ab_12=0;&lt;BR /&gt;leave;&lt;BR /&gt;end;&lt;BR /&gt;end;</description>
      <pubDate>Mon, 04 Dec 2017 19:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418262#M102742</guid>
      <dc:creator>priya1286</dc:creator>
      <dc:date>2017-12-04T19:01:16Z</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/418270#M102745</link>
      <description>&lt;P&gt;&lt;SPAN&gt;end_f = srvc_dt+365;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What about leap years?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 19:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-subscript-out-of-range/m-p/418270#M102745</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-04T19:28:31Z</dc:date>
    </item>
  </channel>
</rss>

