<?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 Simple array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simple-array/m-p/488191#M287357</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;I have a simple array that I want to use, but I did not drop the (i) at the end of the array since I thought it will be the same number as the elements in the array. What I notice though is that it adds a 1 to the number of elements in the array. Do you know why that is happening, and is the a way I can have it reflect the number of the elements in the array?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Here is the array&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Array demography [*] $ C_sex D_DOB D_AGE E_POPULATION;&lt;BR /&gt;do i=1 to dim(demography);&lt;BR /&gt;if demography(i) ne " " then count_demo+1;&lt;BR /&gt;end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I would like i to reflect that there are 4 elements in this array. Is that posible, or should I continue to use a counter?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Mon, 20 Aug 2018 13:31:02 GMT</pubDate>
    <dc:creator>New_to_SAS</dc:creator>
    <dc:date>2018-08-20T13:31:02Z</dc:date>
    <item>
      <title>Simple array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-array/m-p/488191#M287357</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;I have a simple array that I want to use, but I did not drop the (i) at the end of the array since I thought it will be the same number as the elements in the array. What I notice though is that it adds a 1 to the number of elements in the array. Do you know why that is happening, and is the a way I can have it reflect the number of the elements in the array?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Here is the array&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Array demography [*] $ C_sex D_DOB D_AGE E_POPULATION;&lt;BR /&gt;do i=1 to dim(demography);&lt;BR /&gt;if demography(i) ne " " then count_demo+1;&lt;BR /&gt;end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I would like i to reflect that there are 4 elements in this array. Is that posible, or should I continue to use a counter?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 20 Aug 2018 13:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-array/m-p/488191#M287357</guid>
      <dc:creator>New_to_SAS</dc:creator>
      <dc:date>2018-08-20T13:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Simple array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-array/m-p/488194#M287358</link>
      <description>&lt;P&gt;I think you just need to use the DIM function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Array demography [*] $ C_sex D_DOB D_AGE E_POPULATION;
number_of_elements=dim(demography);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 13:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-array/m-p/488194#M287358</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-08-20T13:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Simple array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-array/m-p/488195#M287359</link>
      <description>&lt;P&gt;i has nothing to do with the array.&amp;nbsp; i is an incrementor.&amp;nbsp; The process for the do loop:&amp;nbsp;&lt;SPAN&gt;do i=1 to&amp;nbsp;4;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set i to 1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is i &amp;gt; end of loop&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;No - run code inside&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set i to i + 1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is i &amp;gt; end of loop&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;No - run code inside&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As you can see each time the loop enacts i is incremented, the loop does not run the code enclosed with the loop block when i &amp;gt; 4, however i still gets incremented by 1, as otherwise i would never be greater than the end of loop.&amp;nbsp; What is it your actually trying to achieve (post full example) as:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data have;
  set sashelp.class;
  if _n_=4 then weight=.;
  if _n_=8 then sex="";
run;

data want;
  set have;
  result=nmiss(age,weight,height) + cmiss(sex);
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Is a simpler solution.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 13:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-array/m-p/488195#M287359</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-20T13:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Simple array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-array/m-p/488199#M287360</link>
      <description>&lt;P&gt;"number_of_elements=dim(demography); " worked. Thank you for the responses.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 13:56:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-array/m-p/488199#M287360</guid>
      <dc:creator>New_to_SAS</dc:creator>
      <dc:date>2018-08-20T13:56:54Z</dc:date>
    </item>
  </channel>
</rss>

