Both dosubl and call execute accept raw SAS code as input.  The difference between them is that call execute will take your code and add it to the stack (so, after your data step completes) whilst dosubl will execute your code immediately.

Dosubl is a fantastic function, which I use frequently, but after recently lamenting it’s performance I was asked – just how slow is it compared to call execute?

Well of course the way to find out is to run some tests, which I did as per below.  I created a minimal data step, and switched off logging, and ran the exact same code twice:

options nonotes;
/* dosubl */
data _null_;
 call symputx('start',datetime());
run;
data _null_;
  do x=1 to 500;
  rc=dosubl('data;do stuff=1;end;run;');
  end;
run;
data _null_;
  dur=datetime()-&start;
  call symputx('dosubl',dur);
run;

/* call execute */
data _null_;
  call symputx('start',datetime());
run;
data _null_;
  do x=1 to 500;
  call execute('data;do stuff=1;end;run;');
  end;
run;
data _null_;
  dur=datetime()-&start;
  call symputx('execute',dur);
run;
%put &=dosubl;
%put &=execute;

And the results?  Drum roll please…

As per the log, dosubl finished in 47.6 seconds vs 3.7 seconds for call execute.  Lesson learned?  As useful and incredibly convenient as it is, dosubl is a function that should be used sparingly!