Calling SAS Code From Some Other SAS File

Accepted Solution Solved
Reply
Contributor
Posts: 51
Accepted Solution

Calling SAS Code From Some Other SAS File

Hello!

Sure would appreciate if any of you experts could provide me an efficient way of calling, from an ongoing SAS code some of the SAS code residing in some other file.

Suppose a simple SAS program like the following in a file F:\Temp\Test.sas:

PROC TABULATE DATA=SASHELP.SHOES OUT=TEST;

CLASS REGION SUBSIDIARY PRODUCT;

VAR SALES INVENTORY;

TABLE REGION, REGION*SUBSIDIARY, PRODUCT*SALES PRODUCT*INVENTORY;

RUN;

and another simple program like the one below in a file like D:\AnotherTemp\AnotherTest.sas:

PROC SQL;

CREATE TABLE ABC AS

SELECT COUNT(Name) FROM SASHELP.CLASS WHERE SEX='M';

QUIT;

Now how to call these two programs from the current program file as:

DATA _NULL_;

msg='Some Code 1!'; run;

<<SOME WAY TO GENERATE THE OUTPUT USING THE FILE F:\TEMP\TEST.sas>>

data hello; msg='Some Other Code 2!'; run;

<<SOME WAY TO GENERATE THE OUTPUT USING THE FILE F:\TEMP\D:\AnotherTemp\AnotherTest.sas>>

data bye; msg='Some Other Code 2!'; run;

Your helpful feedback shall be obliged.

Thanx in advance.


Accepted Solutions
Solution
‎09-20-2013 11:52 PM
Super User
Posts: 19,832

Re: Calling SAS Code From Some Other SAS File

Posted in reply to FarazA_Qureshi

Its not in a data step.

You include another program using

%include 'F:\temp\test.sas';

But realize that it will basically run the entire test.sas program.

View solution in original post


All Replies
Solution
‎09-20-2013 11:52 PM
Super User
Posts: 19,832

Re: Calling SAS Code From Some Other SAS File

Posted in reply to FarazA_Qureshi

Its not in a data step.

You include another program using

%include 'F:\temp\test.sas';

But realize that it will basically run the entire test.sas program.

Contributor
Posts: 51

Re: Calling SAS Code From Some Other SAS File

Thanx Reeza! Sure do oblige your valuable reply!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 428 views
  • 1 like
  • 2 in conversation