SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
shl007
Obsidian | Level 7

Hello,

 

What I am struggling with is code to use in my PIPE command when my linux directory has spaces. I see various posts on SAS community that say to surround the path in double quotes, which I am doing. But I still get a path not found error. This is what I have for it. Any ideas? I am pulling my hair out on this 😊. I have tested the code below with a path without spaces, and it works. With spaces seems to be the issue. Thanks for any tips you can provide!

 

filename test pipe 'ls -a "/my path with spaces"';

 

ERROR: Physical file does not exist, /sso/biconfig/940/Lev1/SASApp/ls: cannot access

: No such file or directory.

1 REPLY 1
Tom
Super User Tom
Super User

@shl007 wrote:

Hello,

 

What I am struggling with is code to use in my PIPE command when my linux directory has spaces. I see various posts on SAS community that say to surround the path in double quotes, which I am doing. But I still get a path not found error. This is what I have for it. Any ideas? I am pulling my hair out on this 😊. I have tested the code below with a path without spaces, and it works. With spaces seems to be the issue. Thanks for any tips you can provide!

 

filename test pipe 'ls -a "/my path with spaces"';

 

ERROR: Physical file does not exist, /sso/biconfig/940/Lev1/SASApp/ls: cannot access

: No such file or directory.


The error message you posted makes it look like you forgot the PIPE engine since it looks like it is taking the ls as the filename.

 

Are you sure the path actually exists?  Try just creating a fileref that points to that directory and see if it find the path.  Or try using this macro to test if the directory exists:  https://github.com/sasutils/macros/blob/master/direxist.sas

 

You could also try using Unix escape character (backslash) to protect the spaces.

filename test pipe 'ls -a /my\ path\ with\ spaces';

 

 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 1 reply
  • 1177 views
  • 0 likes
  • 2 in conversation