BookmarkSubscribeRSS Feed
MargoBlue
Fluorite | Level 6

I have a macro: %macro tab(start_date, periods), which creates multiple views dependent on the start date and number of periods.

For example: %tab(201701, 36) creates views: tab_201701, tab_201702,tab_201703,...tab_201912, tab_202001.

 

I want to concatenante this views and create table:

data all_tab;
set WORK.tab_:;
by id1 id2;
run;

/*or*/

data all_tab;
set WORK.tab_: open=defer;
run;

But these views have about from 700 thousands to 1,2 milion records and (only :)) 3 columns.

It takes a long time, and start date as well as number of periods can change (even start_date =201201), so the numer of views can be different. I know that I can create another view as: data all_tab/view=all_tab; ,

but I need the table - to make some operations on its later.

Could you tell me what is better way to make this data step more efficient?:

data all_tab;

set WORK.tab_:;

by id1 id2;

run;

 

I've read about hash tables but I don't know how use it to concatenate views WORK.tab_: and if it works on views.

Thank you in advance.

 

2 REPLIES 2
Reeza
Super User
PROC APPEND will be slightly faster but if you're appending 36 files that are each about 1 million records your main file will be 36 million records, which is a big file, think a few gigabytes.

It all really depends on what you're doing next.
Reeza
Super User
PROC APPEND will be slightly faster but if you're appending 36 files that are each about 1 million records your main file will be 36 million records, which is a big file, think a few gigabytes.

It all really depends on what you're doing next.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 2 replies
  • 469 views
  • 0 likes
  • 2 in conversation