Help using Base SAS procedures

Many-Many merge using Temporary arrays

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

Many-Many merge using Temporary arrays


Hi I was reading this interesting presentation on Many to Many merge without getting the error using temporary Arrays!!!

http://www.sas.com/offices/asiapacific/sp/usergroups/snug/archive/2006/presentations/Q206StephenCrof...

I am interested to know About  the usage

array f{&fcount.,2} _temporary_;   /*HOW and when can we use commas between the lower and upper bounds*/

Thanks


Accepted Solutions
Solution
‎04-07-2013 07:27 PM
Super User
Super User
Posts: 7,050

Re: Many-Many merge using Temporary arrays

Posted in reply to robertrao
HOW and when can we use commas between the lower and upper bounds

How to define the number of dimensions and the lower and upper bounds for any dimension does not depend on whether the array is using normal variables or _temporary_ variables.  The only restriction is that you must specify the bounds for temporary arrays as there is no way for SAS to count the number of variables to figure out the upper bound.


Dimensions are separated by commas in the definition and in any references in your program.  If you want to use lower bounds that do not start with 1 then you can define that using : separator in the definition.



View solution in original post


All Replies
Super Contributor
Posts: 1,041

Re: Many-Many merge using Temporary arrays

Posted in reply to robertrao

data third(keep=a b c);

array f{&fcount.,2}_temporary_;  /*I guess this is the rows,cloumns...when dealing with large datasets how will we khow many columns&rows*/

do i=1 to &fcount.;

set first;

f{i,1}= A;

f{i,2}= B;    /*array name and elements seperated by a comma???*/

end;

do i=1 to &scount.;

set second;

do j=1 to &fcount.;

if a=f{j,1} then

do;

b=f{j,2};

output;

end;

end;

end;

run;

Super User
Posts: 3,254

Re: Many-Many merge using Temporary arrays

Posted in reply to robertrao

It pays to be aware that temporary arrays are held in memory, so there are definite limits to their size. If you try to load a large dataset into a temporary array, say 1 million rows or more, then I suspect you will very soon get out of memory errors.

Where temporary arrays are really powerful, is in complex processing of small to medium size datasets, say thousands, to 100,000's of rows/columns.

Also remember that temporary arrays will not speed up the reading or writing of data to disk as these are limited by your io bandwidth.

Solution
‎04-07-2013 07:27 PM
Super User
Super User
Posts: 7,050

Re: Many-Many merge using Temporary arrays

Posted in reply to robertrao
HOW and when can we use commas between the lower and upper bounds

How to define the number of dimensions and the lower and upper bounds for any dimension does not depend on whether the array is using normal variables or _temporary_ variables.  The only restriction is that you must specify the bounds for temporary arrays as there is no way for SAS to count the number of variables to figure out the upper bound.


Dimensions are separated by commas in the definition and in any references in your program.  If you want to use lower bounds that do not start with 1 then you can define that using : separator in the definition.



🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 179 views
  • 3 likes
  • 3 in conversation