<?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 error in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87638#M25008</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My guess is that you've miscounted the number of variables you're looking at or you have other variables in between check1_5--check42_5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The -- operator specifies that you'll use all variables in between check1_5 and check42_5 and does rely on the order of the variables in the datastep. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Mar 2013 17:10:49 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-03-25T17:10:49Z</dc:date>
    <item>
      <title>Array error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87635#M25005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. I need to update about 231 variables in a dataset so that the response is either a 1 or 0 for a specific number of observations. Right now, the response is a 1 or missing. To do this, I was going to setup an array in SAS so that the responses for all of the 231 variables would update to 0 if the original response was missing and a second variable response is 1. The variables that I want to update are "check1_5" through "check42_5". Variable "fu24yes" is a variable that denotes whether or not that person was part of the 24month followup (so that's the restriction). Do you know what I might be doing wrong? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;data NewVar;&lt;/P&gt;&lt;P&gt;ARRAY MedZero (231) check1_5--check42_5;&lt;/P&gt;&lt;P&gt;DO i = 1 TO 231;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF MedZero(i) = . AND fu24yes=1 THEN MedZero(i) = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Log:&lt;/P&gt;&lt;P&gt;41&amp;nbsp;&amp;nbsp; data NewVar;&lt;/P&gt;&lt;P&gt;42&amp;nbsp;&amp;nbsp; ARRAY MedZero (231) check1_5--check42_5;&lt;/P&gt;&lt;P&gt;ERROR: Variable check1_5 cannot be found on the list of previously defined variables.&lt;/P&gt;&lt;P&gt;ERROR: Too few variables defined for the dimension(s) specified for the array MedZero.&lt;/P&gt;&lt;P&gt;43&amp;nbsp;&amp;nbsp; DO i = 1 TO 231;&lt;/P&gt;&lt;P&gt;45&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF MedZero(i) = . AND fu24yes=1 THEN MedZero(i) = 0;&lt;/P&gt;&lt;P&gt;46&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;47&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 16:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87635#M25005</guid>
      <dc:creator>SASstudent2013</dc:creator>
      <dc:date>2013-03-25T16:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87636#M25006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot create variables with a name range list (double dash).&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 16:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87636#M25006</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-03-25T16:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87637#M25007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data NewVar;&lt;/P&gt;&lt;P&gt; set your_dateset;&lt;/P&gt;&lt;P&gt;ARRAY MedZero(*) check1_5--check42_5;&lt;/P&gt;&lt;P&gt;DO i = 1 TO dim(medzero);&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF MedZero(i) = . AND fu24yes=1 THEN MedZero(i) = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 16:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87637#M25007</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-03-25T16:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87638#M25008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My guess is that you've miscounted the number of variables you're looking at or you have other variables in between check1_5--check42_5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The -- operator specifies that you'll use all variables in between check1_5 and check42_5 and does rely on the order of the variables in the datastep. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 17:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87638#M25008</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-25T17:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87639#M25009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The main problem is that you left out the SET statement in your DATA step.&amp;nbsp; There is no source of incoming data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondarily, you could speed up the program by changing your DO loop:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if fu24yes=1 then do i=1 to dim(medzero);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if MedZero{i}=. then MedZero{i}=0;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your program would be able to check fu24yes just once instead of 231 times, per observation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 17:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87639#M25009</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-03-25T17:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87640#M25010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another minor performance enhancement could replace the inner if:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if MedZero{i}=. then MedZero{i}=0;&lt;/P&gt;&lt;P&gt;with an assignment statement and the coalesce function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MedZero{i}=coalesce(MedZero{i},0);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 18:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87640#M25010</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2013-03-25T18:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Array error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87641#M25011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everyone for your replies. I've updated the code based on your feedback and it worked perfectly. One issue is that I had 231 as the number of variables when it should have been 232. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 18:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-error/m-p/87641#M25011</guid>
      <dc:creator>SASstudent2013</dc:creator>
      <dc:date>2013-03-25T18:31:40Z</dc:date>
    </item>
  </channel>
</rss>

