DATA Step, Macro, Functions and more

Including modules and programs

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 18
Accepted Solution

Including modules and programs

I'm new to SAS EG and also new to IML. I have two similar problems that i have encountered.

 

1. %include does not seem to work as it did in sas base. There i would just give it the location of the sas file and it worked. How do i include a sas file in SAS EG?

 

2. Is there a way to import/include a module that is not defined inside the same proc iml; statement? I'd rather not define all my modules inside my "main" program.

 

Thanks!


Accepted Solutions
Solution
‎03-21-2018 04:40 AM
Super Contributor
Posts: 340

Re: Including modules and programs

Posted in reply to jan_t_lagen

Hello,

 

1. There is no difference between SAS base and EG regarding include statements.

Maybe your SEG is configured to run program on a remote server. So you have either

to deploy the programs you wish to include on the server or execute your programs

locally. Check the menu Tools->Connexions->Servers

 

I don't understand your second question.

View solution in original post


All Replies
Solution
‎03-21-2018 04:40 AM
Super Contributor
Posts: 340

Re: Including modules and programs

Posted in reply to jan_t_lagen

Hello,

 

1. There is no difference between SAS base and EG regarding include statements.

Maybe your SEG is configured to run program on a remote server. So you have either

to deploy the programs you wish to include on the server or execute your programs

locally. Check the menu Tools->Connexions->Servers

 

I don't understand your second question.

Occasional Contributor
Posts: 18

Re: Including modules and programs

1. Okay, Thanks!

 

2. I would like to do something like this:

 

this part would optimally be in another file

/*******/

proc iml;

 start func1(x);

 ..

 finish;

;quit;

/*******/

 

This is in the main file:

/*******/

proc iml;

 y = func1(x);

;quit;

/*******/

Super Contributor
Posts: 340

Re: Including modules and programs

Posted in reply to jan_t_lagen

 

File c:\temp\func.sas

----------------

start func1(x);

 ..

 finish;

---------------

 

File main.sas

-------------------------

proc iml;

%include "c:\temp\func.sas";

 y = func1(x);

;quit;

--------------------------

Super User
Posts: 10,784

Re: Including modules and programs

Posted in reply to jan_t_lagen

Calling @Rick_SAS

SAS Super FREQ
Posts: 4,242

Re: Including modules and programs

Posted in reply to jan_t_lagen

There are three common ways to store/load or %INCLUDE modules. You can choose whichever one appeals to you.

My favorite is to use the STORE statement to store the modules to a library, then use the LOAD statement to load them when needed. That way, the modules are parsed once and stored in compiled form. When they are loaded, they do not need to be re-parsed or re-compiled.

 

If you have a lot of modules, you can use the _ALL_ keyword to store and load them all, thus saving some typing.

 

 

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 128 views
  • 1 like
  • 4 in conversation