DATA Step, Macro, Functions and more

Relative path not getting picked in %INCLUDE for local SAS codes

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Relative path not getting picked in %INCLUDE for local SAS codes

Hi,

 

I am trying to refer SAS codes in %INCLUDE statement for SAS codes on my local machine. I am following the below steps suggested:

 

This setting is maintained per project. To set it:
1.Select File->Project Properties. The Properties window appears.
2.Select the File References tab.
3.Check the box: "Use paths relative to the project for programs and importable files"

I am creating tow SAS codes as:

1.  h:\test\outer.sas

%put outer;

%include "inner.sas";

2. h:\test\inner.sas

%put inner;

 

NOTE: I have also tried saving the Project in the same directory (h:\test)

 

when I execute the SAS code I get the below error:

 

WARNING: Physical file does not exist, /var/applications/sas/config94/Lev1/SASApp/inner.sas.

ERROR: Cannot open %INCLUDE file inner.sas.

 

Can someone help me understand what I am missing to provide the relative path reference?

 

Thanks

Ved Agrawal


Accepted Solutions
Solution
‎12-21-2017 05:22 AM
SAS Super FREQ
Posts: 810

Re: Relative path not getting picked in %INCLUDE for local SAS codes

[ Edited ]
Posted in reply to Ved_Agrawal

The %INCLUDE statement runs on the SAS server and has therefor no knowledge of files on your local machine where the SAS Enterprise Guide runs.

 

I see two ways to do this:

  1. Add your local code to the processflow, as you do with other code and link the programs in your processflow. Use the RightMouseButton and select "Link Program to ..." to draw the connection
  2. Use the "Copy File" Task to copy the .sas files from your local machine to the SAS server, see here for more information https://blogs.sas.com/content/sasdummy/2016/11/14/copy-files-task-moved-menus/

 

 

View solution in original post


All Replies
Super User
Posts: 23,296

Re: Relative path not getting picked in %INCLUDE for local SAS codes

[ Edited ]
Posted in reply to Ved_Agrawal

Where are you saving your EGP files?

and what are you expecting the PUT statement to do in that code?

Occasional Contributor
Posts: 7

Re: Relative path not getting picked in %INCLUDE for local SAS codes

in the same location as the codes are.

 

Occasional Contributor
Posts: 7

Re: Relative path not getting picked in %INCLUDE for local SAS codes

Posted in reply to Ved_Agrawal

From the Put code I just want to understand if I can get in to the inner.sas code.

Super User
Posts: 23,296

Re: Relative path not getting picked in %INCLUDE for local SAS codes

Posted in reply to Ved_Agrawal

Ved_Agrawal wrote:

From the Put code I just want to understand if I can get in to the inner.sas code.


No, %include runs the code in the program inner. 

 

I suspect this this is because SAS is actually on the server, not locally. If you can’t run EG locally, I don’t know if this approach will work. 

Occasional Contributor
Posts: 7

Re: Relative path not getting picked in %INCLUDE for local SAS codes

Yes the SAS is on our serve, but in order to implement Local repository we need to keep all our codes on local server and run it on our remote servers.
I was reading the community space for this issue and there are suggestion of using proc upload for that case, but I wanted to avoid its usage and want to make use of relative SAS paths.
Solution
‎12-21-2017 05:22 AM
SAS Super FREQ
Posts: 810

Re: Relative path not getting picked in %INCLUDE for local SAS codes

[ Edited ]
Posted in reply to Ved_Agrawal

The %INCLUDE statement runs on the SAS server and has therefor no knowledge of files on your local machine where the SAS Enterprise Guide runs.

 

I see two ways to do this:

  1. Add your local code to the processflow, as you do with other code and link the programs in your processflow. Use the RightMouseButton and select "Link Program to ..." to draw the connection
  2. Use the "Copy File" Task to copy the .sas files from your local machine to the SAS server, see here for more information https://blogs.sas.com/content/sasdummy/2016/11/14/copy-files-task-moved-menus/

 

 

Occasional Contributor
Posts: 7

Re: Relative path not getting picked in %INCLUDE for local SAS codes

Posted in reply to Bruno_SAS

Thanks for the solution. Actually I was foolish to try include one SAS code into another, where as SAS EG provides use of Flow for this.

without include it can be simply done as you suggested "Add your local code to the processflow, as you do with other code and link the programs in your processflow. Use the RightMouseButton and select "Link Program to ..." to draw the connection"

 

Regards

Ved Agrawal

☑ This topic is solved.

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

Discussion stats
  • 7 replies
  • 321 views
  • 3 likes
  • 3 in conversation