Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:52:13+00:00 2026-06-14T12:52:13+00:00

I have over 200k small datasets with the same variables (n<1000 and usually n<100)

  • 0

I have over 200k small datasets with the same variables (n<1000 and usually n<100) that I want to concatenate into a master dataset. I have tried using a macro that uses a data step to just iterate through all of the new datasets and concatenate with the master with “set master new:”, but this is taking a really long time. Also, if I try to run at the same time, the call execute data step says that I am out of memory on a huge server box. For reference, all of the small datasets together are just over 5 Gigs. Any suggestions would be greatly appreciated. Here is what I have so far:

%macro catDat(name, nbr) ;
    /*call in new dataset */
    data new ;
    set libin.&name ;
    run ;

    /* reorder names */
    proc sql noprint;
    create table new as 
    select var1, var2, var3
    from new;
    quit;

    %if &nbr = 1 %then %do ;
        data master;
        set new;
        run;
    %end; 
    %if &nbr > 1 %then %do ;
        data master;
        set master new ;
        run;
    %end ;
%mend;

/* concatenate datasets */
data runthis ;
set datasetNames ;
call execute('%catdat('||datasetname||','||_n_||')');
run;

Resolved: see Bob’s comments below.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:52:14+00:00Added an answer on June 14, 2026 at 12:52 pm

    Try using PROC APPEND instead of your “new” dataset; that will be much, much faster:

    %macro DOIT;
    
    proc sql noprint;
       select count(*) into : num_recs
       from datasetNames;
    quit;
    
    %do i=1 %to &num_recs;
    
    data _null_;
      i = &i;
      set datasetNames point=i;
      call symput('ds_name',datasetname);
      stop;
    run; /* UPDATE:  added this line */
    
    %if &i = 1 %then %do;
    /* Initialize MASTER with variables in the order you wish */
    data master(keep=var1 var2 var3);
       retain var1 var2 var3;
       set libin.&ds_name;
       stop;
    run;
    %end;
    
    proc append base=master data=libin.&ds_name(keep=var1 var2 var3);
    run;
    
    %end;
    
    %mend DOIT;
    

    PROC APPEND will add each dataset into your new “master” without rebuilding it each time as you are doing now.
    This also avoids using CALL EXECUTE, removing that memory issue you were running into (caused by generating so much code into the execution stack).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I'm building an application that will have over 30 models, and I want
I have over 1000 images and videos that need to be encrypted. Nothing over
I have over 30 clickable imagebutton views that I want to create programatically instead
I have over 100 fields and I am looking for a way so that
I have over 125 TSV files of ~100Mb each that I want to merge.
I have over 1000 clients and I developed a simple PHP script to loop
We have over 1000 unit tests. A while ago 18 of them started to
We all know the effects that lots of thrown exceptions can have over the
im planning to create a movie file that might have over 16,000 frames?i know
I'm sure it's something simple, but I have over 100 errors like: and: I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.