f



Run a sas program in another sas program

Dear SAS Servlisters:

I am a Stata user, and am trying to learn SAS too. In Stata, in a syntax
file, I can write something:

do dofile1.do
do dofile2.do
do dofile3.do

Then it will invoke dofile1-dofile3 and run the contents in these do
files. So that if I have a series of consecutive data management and
analysis jobs in different do files, I can execute them by running one
file that contains a series of do commands without having to open those
files and run them one by one. This is critical when I don't want to mess
up my analysis with data management; that is, I'd like to put syntax of
different functions (data management and analysis) in different syntax
files. How to do this in SAS? For example I want project1.sas to contain
syntax that manages data set A, while in project2.sas I have syntax to run
a bunch of models using the just-managed data set A. Well, I don't want to
physically open these two files, and physically click the running man to
execute. Instead, can I use a third syntax file, call it doall.sas that
executes project1.sas and project2.sas. Thanks a lot.

Jun Xu
Department of Sociology
Indiana University
0
mystata (5)
10/27/2003 12:33:37 AM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

2 Replies
894 Views

Similar Articles

[PageSpeed] 34

Jun,

Try this:
Create a file called doall.sas that contains the lines

%include 'C:\path to file\project1.sas';
%include 'C:\path to file\project2.sas';

When you execute doall.sas it will run the other two files.
If you don't want to bother opening the SAS interface you can do this as a
batch submit as well.

David

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jun Xu
Sent: Sunday, October 26, 2003 3:34 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Run a sas program in another sas program

Dear SAS Servlisters:

I am a Stata user, and am trying to learn SAS too. In Stata, in a syntax
file, I can write something:

do dofile1.do
do dofile2.do
do dofile3.do

Then it will invoke dofile1-dofile3 and run the contents in these do
files. So that if I have a series of consecutive data management and
analysis jobs in different do files, I can execute them by running one
file that contains a series of do commands without having to open those
files and run them one by one. This is critical when I don't want to mess
up my analysis with data management; that is, I'd like to put syntax of
different functions (data management and analysis) in different syntax
files. How to do this in SAS? For example I want project1.sas to contain
syntax that manages data set A, while in project2.sas I have syntax to run
a bunch of models using the just-managed data set A. Well, I don't want to
physically open these two files, and physically click the running man to
execute. Instead, can I use a third syntax file, call it doall.sas that
executes project1.sas and project2.sas. Thanks a lot.

Jun Xu
Department of Sociology
Indiana University
0
afdbn (102)
10/27/2003 1:06:04 AM
Hi Jun,

Yes, you can do it using batch-mode submit.

a simple example:
c:\xu\project1.sas
c:\xu\project2.sas

c:\xu\doall.sas

in doall.sas wrote:
%inc "c:\xu\project1.sas";
%inc "c:\xu\project2.sas";

In window explorer(suppose you use windowxx), click the file doall.sas and then click right mouse button, you will find a pop-menu choose BATCH SUBMIT.

Hope this helps,
============
Kind Regards,
Zibao Zhang, MD

----- Original Message -----
From: "Jun Xu" <mystata@HOTMAIL.COM>
Newsgroups: bit.listserv.sas-l
To: <SAS-L@LISTSERV.UGA.EDU>
Sent: Monday, October 27, 2003 8:33 AM
Subject: Run a sas program in another sas program


> Dear SAS Servlisters:
>
> I am a Stata user, and am trying to learn SAS too. In Stata, in a syntax
> file, I can write something:
>
> do dofile1.do
> do dofile2.do
> do dofile3.do
>
> Then it will invoke dofile1-dofile3 and run the contents in these do
> files. So that if I have a series of consecutive data management and
> analysis jobs in different do files, I can execute them by running one
> file that contains a series of do commands without having to open those
> files and run them one by one. This is critical when I don't want to mess
> up my analysis with data management; that is, I'd like to put syntax of
> different functions (data management and analysis) in different syntax
> files. How to do this in SAS? For example I want project1.sas to contain
> syntax that manages data set A, while in project2.sas I have syntax to run
> a bunch of models using the just-managed data set A. Well, I don't want to
> physically open these two files, and physically click the running man to
> execute. Instead, can I use a third syntax file, call it doall.sas that
> executes project1.sas and project2.sas. Thanks a lot.
>
> Jun Xu
> Department of Sociology
> Indiana University
>
0
zibaozhang (46)
10/27/2003 9:44:43 AM
Reply: