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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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