DATA Step, Macro, Functions and more

Merging Large Numbers of Dynamic Tables

Accepted Solution Solved
Reply
Super Contributor
Posts: 497
Accepted Solution

Merging Large Numbers of Dynamic Tables

[ Edited ]

I’m looking at doing a rather complex data sorting algorithm using temporary tables.  Before doing it I’d like to check if this will work.  Can I dynamically create a large number of tables e.g. 200 and then merge them together in a set statement dynamically?

 

I'm looking at using this logic for the set statement

 

http://support.sas.com/kb/26/010.html

 

%macro names(prefix,maxnum);
  %do i=1 %to &maxnum;
    &prefix&i
  %end;
  ;
%mend names;

/* Call the macro on the SET statement */

data all;
  set %names(DS,3);
run;

Accepted Solutions
Solution
‎03-28-2016 12:46 PM
Respected Advisor
Posts: 3,799

Re: Merging Large Numbers of Dynamic Tables

Posted in reply to DavidPhillips2

How about a numbered range or name prefix range.

set DS1-DS3;

set DS:;

Also you might find OPEN=DEFER, SET statement option useful.  If your DSs qualify.

View solution in original post


All Replies
Solution
‎03-28-2016 12:46 PM
Respected Advisor
Posts: 3,799

Re: Merging Large Numbers of Dynamic Tables

Posted in reply to DavidPhillips2

How about a numbered range or name prefix range.

set DS1-DS3;

set DS:;

Also you might find OPEN=DEFER, SET statement option useful.  If your DSs qualify.
Super Contributor
Posts: 497

Re: Merging Large Numbers of Dynamic Tables

Posted in reply to data_null__

Thanks data_null_

 

I'll go with your syntax.  Its good to know the huge set won't be an issue.

Respected Advisor
Posts: 3,799

Re: Merging Large Numbers of Dynamic Tables

Posted in reply to DavidPhillips2

It could be that you will run out of memory for data set buffers.  That's where open=defer can be useful but only if all the SETS have the exact same variables with the exact same length etc.

Super User
Posts: 11,343

Re: Merging Large Numbers of Dynamic Tables

Posted in reply to DavidPhillips2

If you are careful with the naming there would be no need for a macro. Since they are temporary then great names like Temp1 to Temp200 suggest themselves. if they are all in the same library then you could use:

 

data want;

   set Temp: ;

run;

The : is a list shortcut that says to use all sets that start with Temp.

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 265 views
  • 2 likes
  • 3 in conversation