DATA Step, Macro, Functions and more

%INCLUDE statement on Linux with uppercase pathname

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

%INCLUDE statement on Linux with uppercase pathname

 I am trying to use an %INCLUDE statement on Linux with an uppercase pathname (which is forced on me, because all user directories start like this). I keep getting "WARNING: Physical file does not exist, '/server1/home/ms/userx/file.txt'. ERROR: Cannot open %INCLUDE file INCL1.", so I assume the problem is with the uppercase pathname, I thought from the documentation that this should be fine if I use quotation marks (I also tried "..." instead of '...' - what I do below works in an interactive session using "...", but not '...', but somehow in batch mode neither seems to work). Or is it something else that I am doing wrong??

 

My code is something like

%macro test(a);
filename incl1 '/SERVER1/home/ms/userx/file.txt';
proc iml; %include inc1; quit;
%mend;
%test(a=1);

and I also tried

%macro test(a);
proc iml; %include '/SERVER1/home/ms/userx/file.txt'; quit;
%mend;
%test(a=1);

 

 

 

I cannot really get around using an include statement, because I need to use a submit statement in PROC IML in order to run some R code via PROC IML (and it appears I cannot have my submit/endsubmit code inside a macro, which this needs to be embedden in for some other reasons to do with parallelizing some simulations). The content of file.txt is some R code plus the submit/endsubmit statements, say:

submit / R;
abc <- 1:15
endsubmit;

Accepted Solutions
Solution
‎06-01-2016 09:54 AM
Respected Advisor
Posts: 3,777

Re: %INCLUDE statement on Linux with uppercase pathname

Can you use ~ to represent /home/username/

 

%inc '~/file.txt';

View solution in original post


All Replies
Super User
Posts: 5,255

Re: %INCLUDE statement on Linux with uppercase pathname

Are you 100% sure that this file exists with your spelling/casing?

And the user that executes the SAS program has access?

Just to rule out the possibility of that is the error message that change the case, not the filename/%include...

Have you tried other files/locations?

Data never sleeps
Solution
‎06-01-2016 09:54 AM
Respected Advisor
Posts: 3,777

Re: %INCLUDE statement on Linux with uppercase pathname

Can you use ~ to represent /home/username/

 

%inc '~/file.txt';
Contributor
Posts: 25

Re: %INCLUDE statement on Linux with uppercase pathname

Thanks, using "~..." was a great suggestion. That worked and solved my very specific problem, I guess a more general answer would be useful for the future, too, but I will accept this as the solution for my current problem.

Super User
Super User
Posts: 6,498

Re: %INCLUDE statement on Linux with uppercase pathname

Can you run some Unix commands from SAS to see what is going on?

data _null_;
   input cmd $80. ;
   infile cmd pipe filevar=cmd end=eof;
   put cmd=;
   do while (not eof);
      input ;
      put _infile_;
   end;
cards;
pwd
ls -ld ~
ls -ld /server1/home
ls -ld /SERVER1/home
;;;;

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 329 views
  • 1 like
  • 4 in conversation