Your SAS programs, embedded in web apps and elsewhere

Proc stream: %include from folder

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Proc stream: %include from folder

Hello,

I have started creating a dynamics website using Stored processes and Proc stream.

I am trying to load a .sas stored process via the %include statement. Using the following code, everything works just fine when the sas file is in the root directory:

label;

%include MyProcess;


To organize the .sas files, I want to move them to sub folders. However I can't figure out how to specify this subfolder. I tried the following, but they don't work

%include SubFolder/MyProcess;

%include "SubFolder/MyProcess";

%include 'SubFolder/MyProcess';

%include "/SubFolder/MyProcess";

%include '/SubFolder/MyProcess';

%include SubFolde\MyProcess;

%include "SubFolder\MyProcess";

%include 'SubFolder\MyProcess';

%include "\SubFolder\MyProcess";

%include '\SubFolder\MyProcess';

I am not allowed to use hardcoded paths, so the documentation solution is not useable.

Base SAS(R) 9.4 Procedures Guide, Third Edition

Thanks for any suggestions in advance.


Accepted Solutions
Solution
‎02-27-2015 10:29 AM
Super User
Super User
Posts: 7,039

Re: Proc stream: %include from folder

You can use relative paths.

So to get a file from a sub-folder you could use


%inc "subfolder/myfile.sas";

(Note that SAS is happy to convert / to \ if you are running on Windows instead of Unix.  Or vice versa.)

But they will be relative to the current working directory and not necessarily to the directory where the source code file is located.

In that case you might want to assign a fileref to the top level directory.

FILENAME CODELIB '/myproject/folder/';

%inc codelib("subfolder/myfile.sas");

View solution in original post


All Replies
Trusted Advisor
Posts: 1,301

Re: Proc stream: %include from folder

You need to use the relative path.

Solution
‎02-27-2015 10:29 AM
Super User
Super User
Posts: 7,039

Re: Proc stream: %include from folder

You can use relative paths.

So to get a file from a sub-folder you could use


%inc "subfolder/myfile.sas";

(Note that SAS is happy to convert / to \ if you are running on Windows instead of Unix.  Or vice versa.)

But they will be relative to the current working directory and not necessarily to the directory where the source code file is located.

In that case you might want to assign a fileref to the top level directory.

FILENAME CODELIB '/myproject/folder/';

%inc codelib("subfolder/myfile.sas");

New Contributor
Posts: 3

Re: Proc stream: %include from folder

Thanks for the help.

Using FILENAME CODELIB '/myproject/folder/'; is even better since I can set a completely new working directory.

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 478 views
  • 3 likes
  • 3 in conversation