<?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 SAS Aarray Question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Aarray-Question/m-p/32162#M6206</link>
    <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am using a sas array to define 40 consecutive 1-byte fields starting at pos 11.  These are character fields hence the '--'.  But i am getting this error when I try to run the pgm.  What am i doing wrong?  Thank you !!&lt;BR /&gt;
&lt;BR /&gt;
DATA A;&lt;BR /&gt;
INFILE IN1;&lt;BR /&gt;
INPUT @01     EID     $CHAR10.&lt;BR /&gt;
          @11     INDABC -- INDXYZ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ERROR:&lt;BR /&gt;
Variable INDABC cannot be found on the list of previously defined variables</description>
    <pubDate>Thu, 17 Jul 2008 19:49:35 GMT</pubDate>
    <dc:creator>KevinC_</dc:creator>
    <dc:date>2008-07-17T19:49:35Z</dc:date>
    <item>
      <title>SAS Aarray Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Aarray-Question/m-p/32162#M6206</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am using a sas array to define 40 consecutive 1-byte fields starting at pos 11.  These are character fields hence the '--'.  But i am getting this error when I try to run the pgm.  What am i doing wrong?  Thank you !!&lt;BR /&gt;
&lt;BR /&gt;
DATA A;&lt;BR /&gt;
INFILE IN1;&lt;BR /&gt;
INPUT @01     EID     $CHAR10.&lt;BR /&gt;
          @11     INDABC -- INDXYZ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ERROR:&lt;BR /&gt;
Variable INDABC cannot be found on the list of previously defined variables</description>
      <pubDate>Thu, 17 Jul 2008 19:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Aarray-Question/m-p/32162#M6206</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2008-07-17T19:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Aarray Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Aarray-Question/m-p/32163#M6207</link>
      <description>Hi:&lt;BR /&gt;
  This isn't really a SAS Array question. I don't see a DO loop in your program, where you would be treating the 40 variables like an array, nor do I see an ARRAY statement which would set up the array referencing structure.&lt;BR /&gt;
&lt;BR /&gt;
  A SAS array is NOT a permanent data construct. It is a way to group variables together and reference them like they were in an array. If you create vars Ind1-Ind40, SAS stores those variables as 40 separate variables. If you have a program that references those variables in an ARRAY statement and you have a DO loop that does something in the array:&lt;BR /&gt;
[pre]&lt;BR /&gt;
array ind $ ind1-ind40;&lt;BR /&gt;
  do i = 1 to 40;&lt;BR /&gt;
      if ind(i) = 'a' then &lt;BR /&gt;
        put ind(i)= i=;&lt;BR /&gt;
  end;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                               &lt;BR /&gt;
--- you might use the reference IND(i), but SAS never stores IND(i) -- it only stores IND1-IND40. And, you don't need an ARRAY to read the data into SAS format.&lt;BR /&gt;
&lt;BR /&gt;
However, to indicate a character variable in an INPUT statement, you need to use the $ to tell the INPUT statement that you are reading a character value (and not a number). Generally the "--' indicator has meaning as a way to reference all the variables between two variables, as they are stored in the descriptor portion of the SAS dataset. However, in your program, you don't -have- a descriptor portion yet -- your INPUT statement is just -building- one, so you'd have to use a different form of INPUT statement for reading a series of values into a bunch of related variable names:&lt;BR /&gt;
 &lt;BR /&gt;
[pre]&lt;BR /&gt;
DATA A1;&lt;BR /&gt;
length eid $10;&lt;BR /&gt;
INFILE datalines;&lt;BR /&gt;
            &lt;BR /&gt;
INPUT @01 EID $CHAR10.&lt;BR /&gt;
      @11 (Ind1-Ind40) ($1.);&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
abc1234567abcdefghijklmnopqrstuvwxyz1234567890*$+=&lt;BR /&gt;
xyz1234567zyxwvutsrqponmlkjihgfedcba1234567890=+$*&lt;BR /&gt;
pqr1234567abcdefghijklmzyxwvutsrqpon1234567890+=*$&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
         &lt;BR /&gt;
options nocenter linesize=200;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc print data=a1;&lt;BR /&gt;
title 'what does the data look like';&lt;BR /&gt;
run;&lt;BR /&gt;
              &lt;BR /&gt;
proc contents data=work.a1;&lt;BR /&gt;
title 'what variables were created in work.a1';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre] &lt;BR /&gt;
             &lt;BR /&gt;
Note how the INPUT statement has the (IND1-IND40) and ($1.)  -- the way I think of describing how this INPUT statement works is: &lt;B&gt;&lt;BR /&gt;
starting at position 11 in the INPUT file, make me 40 variables named IND1-IND40 by using the $1. informat for each of the 40 variables.&lt;/B&gt; What happens is that SAS reuses the informat in the parentheses over and over again until it gets to the end of the dataline.&lt;BR /&gt;
&lt;BR /&gt;
Or, if you didn't want numbered variables, then you'd have to do something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
INPUT @01 EID $CHAR10.&lt;BR /&gt;
      @11 (Indaba Indabb Indabc Indabd Indabe&lt;BR /&gt;
           Indabf Indabg Indabh Indabi Indabj&lt;BR /&gt;
           Indabk Indabl Indabm Indabn Indabo&lt;BR /&gt;
           Indabp Indabq Indabr Indabs Indabt&lt;BR /&gt;
           Indabu Indabv Indabw Indabx Indaby&lt;BR /&gt;
           Indabz Indbba Indbbb Indbbc Indbbd&lt;BR /&gt;
           Indbbe Indbbf Indbbg Indbbh Indbbi&lt;BR /&gt;
           Indbbj Indbbk Indbbl Indbbm Indbbn) ($1.);&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                 &lt;BR /&gt;
But, you can't just use the indaba--indbbn list method in the INPUT statement because it is the INPUT statement that is putting those variable names in the descriptor of the SAS dataset. I suppose if you have a LENGTH statement that listed all the variables, then you could use the -- reference ...but if you're going to need to list them, anyway, may as well do it in the INPUT statement.&lt;BR /&gt;
 &lt;BR /&gt;
Then LATER, if you need to reference these variables in a variable list, you could do:&lt;BR /&gt;
[pre]&lt;BR /&gt;
array ind $ ind1-ind40;&lt;BR /&gt;
array othr $ indaba--indbbn;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 17 Jul 2008 22:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Aarray-Question/m-p/32163#M6207</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-07-17T22:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Aarray Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Aarray-Question/m-p/32164#M6208</link>
      <description>I'd like to suggest to KevinC that he should just use one variable, $40 wide.&lt;BR /&gt;
My reasoning is that it is so very much simpler to load and pass around one item than 40. &lt;BR /&gt;
If and when the individual indicators are required, they can be pulled out of the collection with a simple substring function. &lt;BR /&gt;
&lt;BR /&gt;
Is there a contra- argument that suggests the 40 are more convenient and informative when separate than as a collection?&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Fri, 18 Jul 2008 12:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Aarray-Question/m-p/32164#M6208</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-07-18T12:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Aarray Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Aarray-Question/m-p/32165#M6209</link>
      <description>Thank you both so much for such detailed explaination !!!&lt;BR /&gt;
 &lt;BR /&gt;
I guess my original question had to do with "using shortcuts for name variable list".  i was gonna use it in an array later in the program.  &lt;BR /&gt;
&lt;BR /&gt;
Just to make sure i understand this, 'numbered varialbes' and 'name variables' are defined differently in the INPUT statement.  i think thats where my problem was.&lt;BR /&gt;
&lt;BR /&gt;
Thank you so much again !!</description>
      <pubDate>Mon, 21 Jul 2008 13:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Aarray-Question/m-p/32165#M6209</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2008-07-21T13:57:17Z</dc:date>
    </item>
  </channel>
</rss>

