<?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: Unknown upper bound array in listing variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372242#M88975</link>
    <description>&lt;P&gt;Its telling you there are no variables with start prefix. &amp;nbsp;Your code seems confused, why is the set &amp;lt;dataset&amp;gt; within the do loop?&lt;/P&gt;
&lt;P&gt;Your code should look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data...;
  set mods.mcare...;
  by usrds_id;
  array startx start:;
  ...;
  do i=1 to dim(startx);
    ...;
  end;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 30 Jun 2017 16:31:06 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-06-30T16:31:06Z</dc:date>
    <item>
      <title>Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372229#M88960</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have array code that works just fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array startx(3) start1 start2 start3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i have more than 3 possibles and i want to run it as an unknown upperbound.&amp;nbsp; I know this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array startx(*)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do i=1 to dim(startx);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and all that, but i can't figure out how to give a default base name so that sas can just number them as they come across them.&amp;nbsp; Is there a way to do that?&amp;nbsp; I've tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array startx(*) start:;&lt;/P&gt;&lt;P&gt;array startx(*) start*:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and nothing works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that i can put a count into a macro variable and use that but because i'm working with millions of records and i'd rather not add the processing time.&amp;nbsp; I was hoping i could do it right in the array line.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Megan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372229#M88960</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-06-30T16:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372231#M88961</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;PRE&gt;data have;
  start1=1; start2=3; start3=4;
run;
data want;
  set have;
  array startx start:;
  do i=1 to dim(startx);
    startx{i}=9;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Although if you have lots of counts you would probably be better off having a normalised structure with data going down rather than across.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372231#M88961</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-30T16:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372234#M88963</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; The data is currently going down and i want it to go across so i can compare end to start dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Doing it without the () and using the wildcard i'm getting warning saying it defined an array with zero elements.&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>Fri, 30 Jun 2017 16:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372234#M88963</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-06-30T16:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372236#M88965</link>
      <description>&lt;P&gt;Sorry, I can't see your code/data or log??&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372236#M88965</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-30T16:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372239#M88973</link>
      <description>&lt;P&gt;I'm on an enclave computer that has no copy function or internet (security you know!).&amp;nbsp; I can't copy anything over.&amp;nbsp; The best i can do is a screenshot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the arrays are the normal "startx (3) start1 - start3" it runs just fine.&amp;nbsp; I just need to know how to not have to write out start3.&amp;nbsp; Leave it open for sas to fill.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10052iAA8A73E1D4F6AA38/image-size/original?v=1.0&amp;amp;px=-1" alt="array.png" title="array.png" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372239#M88973</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-06-30T16:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372241#M88974</link>
      <description>&lt;P&gt;By "the data is going down" do you mean that the "array" of values you want comes from the rows of data (i.e. one row per array element)?&amp;nbsp; If so then the array size would equal the number of obs in the data set, which is easily determined.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you also say you want to "compare end to start dates", which I guess means the date in the first obs vs the date in the last obs.&amp;nbsp; In that case you don't even need the array.&amp;nbsp; Just read the first obs and also used the "point=" option to read the last obs without reading any obs in between:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have (obs=1)&amp;nbsp;&amp;nbsp; nobs=nrows;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have (keep=date rename=(date=last_date)) point=nrows;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; last_minus_first=last_date - date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; put date=date9.&amp;nbsp; last_date=date9. last_minus_first=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372241#M88974</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-06-30T16:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372242#M88975</link>
      <description>&lt;P&gt;Its telling you there are no variables with start prefix. &amp;nbsp;Your code seems confused, why is the set &amp;lt;dataset&amp;gt; within the do loop?&lt;/P&gt;
&lt;P&gt;Your code should look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data...;
  set mods.mcare...;
  by usrds_id;
  array startx start:;
  ...;
  do i=1 to dim(startx);
    ...;
  end;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372242#M88975</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-30T16:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372243#M88976</link>
      <description>&lt;P&gt;I think we have here another clear example of why following the guidance by the Post button is so key to getting clear answers.&lt;/P&gt;
&lt;P&gt;1) Post test data in the form of a datastep&lt;/P&gt;
&lt;P&gt;2) Post example required output&lt;/P&gt;
&lt;P&gt;3) Explain logic between the two&lt;/P&gt;
&lt;P&gt;4) Provide code/logs where present&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We are just guessing here.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372243#M88976</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-30T16:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372244#M88977</link>
      <description>&lt;P&gt;I have 2 million rows of data, multiple rows per id, and i want one row per id with all of the start and end values on a single row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i'm going from "long to wide" i always put the arrays first listing out the new variables that i want to have in the new dataset i'm trying to create.&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>Fri, 30 Jun 2017 16:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372244#M88977</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-06-30T16:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372245#M88978</link>
      <description>&lt;P&gt;I know the upper bound can be determined before hand, i said that in my initial post.&amp;nbsp; What i also said is that because i'm working with millions of records, i'd rather not add to the processing time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like your option only allows me to compare two dates.&amp;nbsp; I have multiple dates per id that i would like to see all on one line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372245#M88978</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-06-30T16:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372248#M88979</link>
      <description>&lt;P&gt;Frankly, either there's a way to let sas determine the upper bound array name or there isn't.&amp;nbsp; Me posting code isn't going to change whether or not someone knows if that's even possible.&amp;nbsp; And i did post the array line.&amp;nbsp; THe one line i needed help with.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372248#M88979</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-06-30T16:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372250#M88980</link>
      <description>&lt;P&gt;And following on from the minimum information you provided in the your first post:&lt;/P&gt;
&lt;P&gt;---&lt;/P&gt;
&lt;P&gt;array startx(3) start1 start2 start3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i have more than 3 possibles and i want to run it as an unknown upperbound.&amp;nbsp; I know this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array startx(*)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i=1 to dim(startx);&lt;/P&gt;
&lt;P&gt;---&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created this code, which runs fine:&lt;/P&gt;
&lt;PRE&gt;data have;
  start1=1; start2=3; start3=4;
run;
data want;
  set have;
  array startx start:;
  do i=1 to dim(startx);
    startx{i}=9;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Now you are telling us that your data does not have variables start1 start2 etc. &amp;nbsp;Your data looks something like this:&lt;/P&gt;
&lt;P&gt;START &amp;nbsp;END &amp;nbsp; MCARE&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you are putting these one by one up into variables, correct? &amp;nbsp;This is different as there is no way for the datastep to know how many elements until the end.&lt;/P&gt;
&lt;P&gt;So then you have several options:&lt;/P&gt;
&lt;P&gt;- Find out how many items there are before your datastep;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  select max(count(start))
  into  :items
  from  have
  group by urds_id;
quit;

data want;
  set have;
  array startx{&amp;amp;items.)...;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will likely be the quickest method.&lt;/P&gt;
&lt;P&gt;You could do three transposes.&lt;/P&gt;
&lt;P&gt;Or create a large array that will be bigger than you will ever get to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:55:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372250#M88980</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-30T16:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372252#M88981</link>
      <description>&lt;P&gt;Correct, i only have start and end.&amp;nbsp; I wanted to create start1 - start?.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And i want to know if SAS can determine the "?" for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 16:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372252#M88981</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-06-30T16:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372253#M88982</link>
      <description>&lt;P&gt;HBOUND()&lt;/P&gt;
&lt;P&gt;LBOUND()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71196"&gt;@MeganE&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Frankly, either there's a way to let sas determine the upper bound array name or there isn't.&amp;nbsp; Me posting code isn't going to change whether or not someone knows if that's even possible.&amp;nbsp; And i did post the array line.&amp;nbsp; THe one line i needed help with.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can short cut your variable list as well if you have a common prefix:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array myVars(*) Start: ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you're trying to automate the declaration of a macro that's going to be difficult, you need to precalculate the number, into a macro variable and work with that. The other option is to use PROC TRANSPOSE and then you don't need to know any of that. If you have multiple variables you'll need multiple transposes and a merge.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 17:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372253#M88982</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-30T17:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372255#M88983</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71196"&gt;@MeganE&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I know the upper bound can be determined before hand, i said that in my initial post.&amp;nbsp; What i also said is that because i'm working with millions of records, i'd rather not add to the processing time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like your option only allows me to compare two dates.&amp;nbsp; I have multiple dates per id that i would like to see all on one line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If those dates are not on the same record than an array, at least at the begining, is not going to work as arrays only exist for variables on a single record. What you will need to do is to transpose the data so those dates are one a single row&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;PRE&gt;data example;
   do id = 1 to 3;
      do j= 1 to 5;
         date = today() + id +j; /* just to have some variety in the dates*/
         output;
      end;
   end;
   format date mmddyy10.;
run;

proc transpose data=example out=extrans
   prefix=start ;
by id;
var date;
run;&lt;/PRE&gt;
&lt;P&gt;However with "millions" of records depending on how many ids and dates are concerned this might be a longish program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you are looking at end dates you would need to make two separate transproses and then merge the two transposed sets to get both variables on the same row.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 17:19:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372255#M88983</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-30T17:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372256#M88984</link>
      <description>&lt;P&gt;So right now, sas doesn't have the ability to determine an upper bound array when using an array to create new variables.&amp;nbsp; That's what i'm hearing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 17:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372256#M88984</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-06-30T17:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372267#M88992</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71196"&gt;@MeganE&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;So right now, sas doesn't have the ability to determine an upper bound array when using an array to create new variables.&amp;nbsp; That's what i'm hearing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not quite&amp;nbsp;because what you are appently attempting to do&amp;nbsp;seems not to be&amp;nbsp;an array at all.&lt;/P&gt;
&lt;P&gt;You can create an array of missing values with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array x (25);&amp;nbsp; Which will create variables x1 through x25.&lt;/P&gt;
&lt;P&gt;Optionally you can supply&amp;nbsp;initial values BUT you have to &lt;STRONG&gt;explicitly&lt;/STRONG&gt; indicate how many variables you are creating so that SAS can set aside storage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use existing variables then you have to indicate the names in one way or another&lt;/P&gt;
&lt;P&gt;Explicit list of ALREADY EXISTING variables&lt;/P&gt;
&lt;P&gt;array y&amp;nbsp;&amp;nbsp; varname thisvar other;&lt;/P&gt;
&lt;P&gt;or numbered list of existing variables:&lt;/P&gt;
&lt;P&gt;array z var1 - var35;&lt;/P&gt;
&lt;P&gt;or a list of EXISTING variables that start with similar characters&lt;/P&gt;
&lt;P&gt;array a&amp;nbsp; ext: mnt: ; would place all variables that start with EXT or MNT into the array&lt;/P&gt;
&lt;P&gt;or a list of contiguous variables that are in column order in a data set:&lt;/P&gt;
&lt;P&gt;array b&amp;nbsp; varincolum5 -- anothervarincolum15;&amp;nbsp; note the two - that is the contiguous column list definer.&lt;/P&gt;
&lt;P&gt;you can mix the approaches but all of those reference variables in the same observation (or same row ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you need to provide something to build an array with a fixed number of elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your description, since you haven't provided even a 10 row example of data an what you are trying to actually do, sounds like you want to look at elements across rows. Which is the perview of PROC IML and the matrix language or reshaping the data so all of the values you want are on a single row. An array cannot ever in a data step look across rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some languages include structures called a Lists or stacks that may behave as you want but those both require an entirely differentl approach to data storage.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 18:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372267#M88992</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-30T18:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372271#M88994</link>
      <description>&lt;P&gt;Thanks, but, again, i do not want to use existing variables.&amp;nbsp; I am trying to create new variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just talked to sas support, and they have confirmed that sas cannot determine the upperbound of an array that is being used to create BRAND NEW VARIABLES during the process.&amp;nbsp; It has to be figured out beforehand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 18:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372271#M88994</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-06-30T18:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372279#M88995</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71196"&gt;@MeganE&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just talked to sas support, and they have confirmed that sas cannot determine the upperbound of an array that is being used to create BRAND NEW VARIABLES during the process.&amp;nbsp; It has to be figured out beforehand.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sounds right.&amp;nbsp; Rember that the ARRAY statement does its work at COMPILE time.&amp;nbsp; If you are using an array statement to create new variables (at compile time), you need to tell the array statement how many variables to create.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There have been times I've hoped there might be a syntax like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  x1=1; x2=2; x3=3;

  array x{*} x: ;

  array y{dim(x)} ; *pseudocode;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think that is something like what you might have been hoping for?&amp;nbsp; But that doesn't work because the dim() function works at execution time.&amp;nbsp; Even if it did work at compile time, The only allowed arguments to specify the number of elements in an array are an integer or *.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, I think you are forced to pre-compute the number of variables you want in the array in SAS, because there is no way for SAS to compute it.&amp;nbsp; (There are often ways to do this computation dynamically so that it isn't hardcoded.)&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 18:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372279#M88995</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-06-30T18:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Unknown upper bound array in listing variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372306#M89000</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71196"&gt;@MeganE&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;So right now, sas doesn't have the ability to determine an upper bound array when using an array to create new variables.&amp;nbsp; That's what i'm hearing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is not true at all. SAS can always determine how many variables you have specified for an array.&lt;/P&gt;
&lt;P&gt;What you are asking for is how to generate a program that will convert an unknown number of OBERVATIONS into variables.&lt;/P&gt;
&lt;P&gt;So yes in that limited situation SAS cannot figure out what would be an ideal upper bound for your array. You will need to tell it what upper bound to use. (or lower bound for that matter).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could calculate an estimate. &amp;nbsp;Perhaps based on how many observations are in the source data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint; select count(*) into :upper trimmed from have ; quit;
data want ;
   set have ;
   array start (&amp;amp;upper) ;
   ...
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps you are doing BY variable processing so you only need enough for the largest group.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint; 
  select max(nobs) into :upper trimmed 
  from (select byvar,count(*) as nobs from have group by byvar)
  ; 
quit;
data want ;
  do _n_=1 by 1 until (last.byvar);
     set have ;
     by byvar;
     array start (&amp;amp;upper) ;
     start(_n_)= myvar ;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could just pick an upperbound that is larger than you expect to need. &amp;nbsp;You can even make the code smoothly deal with the sitiation where it is not large enough. &amp;nbsp;For example by just starting another output observation.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  do _n_=1 to 200 until (last.byvar);
    set have ;
    by byvar;
    array start (200) ;
    start(_n_)= myvar ;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 21:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unknown-upper-bound-array-in-listing-variables/m-p/372306#M89000</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-30T21:33:46Z</dc:date>
    </item>
  </channel>
</rss>

