<?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: Why does SAS think an array element/variable is neither missing nor nonmissing? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298287#M62719</link>
    <description>&lt;P&gt;If array dates is not assigned to proper variables, this condition&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if year(dates{i}) eq yearbefore then do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can never be true and the do block will never execute.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2016 12:15:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-09-14T12:15:25Z</dc:date>
    <item>
      <title>Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298284#M62716</link>
      <description>&lt;P&gt;Hello SAS Community:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a data step with a series of arrays and loops...a simplified version below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data out;
set in;
%let d=500;
array codes{&amp;amp;d}; *codes1-codes500 already exist in "n";
array dates{&amp;amp;d}; *same as above;
array maingroup{14}; *we create array and use like variables;

do i=1 to &amp;amp;d;
 if year(dates{i}) eq yearbefore then do;
   currgroup=substr(codes{i},1,1);
   if missing(maingroup{1}) then maingroup{1}=currgroup;
end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;the "maingroup1" var from the declared array never sets properly. Even when i put "if not missing(maingroup{1}) it doesn't set it. So whether or not i say maingroup{1} (or maingroup1 for that matter) is missing or not missing, it won't set the variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone explain what state this array element/variable has if it is neither missing nor not missing?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks ahead of time.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298284#M62716</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-09-14T12:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298285#M62717</link>
      <description>&lt;P&gt;You need to tell SAS which variables from the PDV belong to an array, otherwise the array is created with new variables and always set to missing at the start of a data step iteration.&lt;/P&gt;
&lt;P&gt;Do it like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array codes{&amp;amp;d} atc1-atc&amp;amp;d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298285#M62717</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-14T12:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298286#M62718</link>
      <description>Hi Kurt,&lt;BR /&gt;&lt;BR /&gt;Thank you for responding but this doesn't answer the question. The codes arrays are fine (when the variables exist matching array declared they stick just fine), the problem seems to be with the maingroup{14} which does not set properly and has neither missing nor not missing state.</description>
      <pubDate>Wed, 14 Sep 2016 12:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298286#M62718</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-09-14T12:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298287#M62719</link>
      <description>&lt;P&gt;If array dates is not assigned to proper variables, this condition&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if year(dates{i}) eq yearbefore then do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can never be true and the do block will never execute.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298287#M62719</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-14T12:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298288#M62720</link>
      <description>&lt;P&gt;That isn't true, the do block executes just fine, because the dates array exist in variables, and the currgroup variable sets just fine. The problem (once again) is that the maingroup arrays does not create seem to make the maingroup1-maingroup14 variables, because they do not have a state of missing or nonmissing.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298288#M62720</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-09-14T12:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298290#M62721</link>
      <description>&lt;P&gt;Please supply some test data to demonstrate that effect.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298290#M62721</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-14T12:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298292#M62722</link>
      <description>&lt;P&gt;There are several red flags that may be nothing, may be carelessness, or may be a real issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you looking at maingroup14?&amp;nbsp; There is nothing in your program that would assign a value to maingroup14.&amp;nbsp; The is a hard-coded reference to maingroup1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The name of the array is maingroup&lt;STRONG&gt;s&lt;/STRONG&gt;, not maingroup.&amp;nbsp; So the elements are maingroup&lt;STRONG&gt;s&lt;/STRONG&gt;1-maingroup&lt;STRONG&gt;s&lt;/STRONG&gt;14.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The earlier array elements must be correct.&amp;nbsp; For example, the elements of the DATES array must be legitimate dates (not datetimes).&amp;nbsp; And the elements of the CODES array must be character (numeric would cause the results you are describing), and must be left-hand justified.&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>Wed, 14 Sep 2016 12:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298292#M62722</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-14T12:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298294#M62723</link>
      <description>&lt;P&gt;You should also recheck your code. You reference array maingroup in the do block, but declare array maingroup&lt;U&gt;&lt;STRONG&gt;s&lt;/STRONG&gt;&lt;/U&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298294#M62723</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-14T12:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298295#M62724</link>
      <description>&lt;P&gt;You declared an array like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; maingroups&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;14&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;*we create array and use like variables;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and you are accessing it as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;  &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;maingroup&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; maingroup&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;currgroup&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two are different for SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298295#M62724</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2016-09-14T12:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298297#M62725</link>
      <description>This did it -- the maingroup array i just had to declare as a character array:&lt;BR /&gt;&lt;BR /&gt;array maingroup{14} $;&lt;BR /&gt;&lt;BR /&gt;and now it is behaving in setting the code (string)</description>
      <pubDate>Wed, 14 Sep 2016 12:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298297#M62725</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-09-14T12:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298298#M62726</link>
      <description>Hi datasp,&lt;BR /&gt;&lt;BR /&gt;Sorry this was me just typo'ing when getting the code typed into forum... issue was character format of codes arrays which was not setting numeric maingroup array properly..</description>
      <pubDate>Wed, 14 Sep 2016 12:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298298#M62726</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-09-14T12:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298299#M62727</link>
      <description>&lt;P&gt;When you look at the log, you will see NOTEs about conversion of numeric values to character values. These should ALWAYS raise a red flag for you, as they may cause bootloads of unexpected problems (as you just experienced).&lt;/P&gt;
&lt;P&gt;Good code never has those NOTEs.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298299#M62727</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-14T12:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298300#M62728</link>
      <description>Thanks Kurt you're right, the NOTEs i do not take as seriously as I should. I appreciate your time and assistance this afternoon.</description>
      <pubDate>Wed, 14 Sep 2016 12:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298300#M62728</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-09-14T12:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why does SAS think an array element/variable is neither missing nor nonmissing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298301#M62729</link>
      <description>&lt;P&gt;Then place $ after maingroups and you can size it with a numeric if it is more than 8&lt;/P&gt;&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; maingroups&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;14&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;} $&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-does-SAS-think-an-array-element-variable-is-neither-missing/m-p/298301#M62729</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2016-09-14T12:45:54Z</dc:date>
    </item>
  </channel>
</rss>

