BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

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;
1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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

4 REPLIES 4
data_null__
Jade | Level 19

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.
DavidPhillips2
Rhodochrosite | Level 12

Thanks data_null_

 

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

data_null__
Jade | Level 19

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.

ballardw
Super User

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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