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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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