You actually have two problems to solve. You also have to ensure that program A completes before program B begins. The easiest way to do that is to create program C to run both A then B:
%include 'program_a.sas';
%include 'program_b.sas';
There are other approaches that involve PROC PRINTTO, but %INCLUDE should be easiest and safest.