BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jorn
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

3 REPLIES 3
FriedEgg
SAS Employee

You need to use the relative path.

Tom
Super User Tom
Super User

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");

Jorn
Calcite | Level 5

Thanks for the help.

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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