filename DIRLIST pipe 'dir "C:\Temp\Temp\Temp2" /s'; data dirlist ; length buffer $256 ; infile dirlist length=reclen ; input buffer $varying256. reclen ; run ;
I have tried this code and it is not working at all.
Is it possible to get the files listing of a directory hosted on c drive while using SAS EG on unix server
"Not working" is awful vague.
Are there errors in the log?: Post the code and log in a code box opened with the "</>" to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.
Strongly suspect that your EG is connecting to a server on the network and that your local C: drive is not mapped to be seen by the server, or if it is mapped is not referred to as "C:" from the server's viewpoint.
options xcmd;
x "/mnt/c/Temp/Temp/Temp2/";
%let path=C:\Temp\Temp\Temp2;
%let path=/mnt/c/Temp/Temp/Temp2/;
filename DIRLIST pipe 'dir "&path." /s';
data dirlist ;
length buffer $256 ;
infile dirlist length=reclen ;
input buffer $varying256. reclen ;
run ;
In the first window, you will see the error messages while in the second one, you will see my SAS code. The first %let path statement is the real location of my directory. The second %let path statement is something I saw on the web for Unix but it does not work better.
You have mentionned that my C drive is not mapped or not visible from our Unix server.
Is there anything I could do in term of SAS code to do that ? Please note that our Unix server is access through a vpn connection. With WinScp , it is possible to see the C drive and all the folders on our Unix server but Winscp is not SAS EG.
Is there a work around solution possible?
I think you will need to work with your unix admin to try and get your C: drive (or more likely a windows network drive) mounted to unix so that unix can see the files there.
Your second path you got from the internet:
/mnt/c/Temp/Temp/Temp2/
likely shows a case where the user had mounted a windows folder to unix ( /mnt is a common abbreviation for mount ).
WinSCP can see your C: drive because it is running on Windows.
EG can see your C: drive because EG is running on Windows.
When you use EG to submit SAS code to a unix server, the SAS job can only see files that are available to the unix server where it is running.
@alepage wrote:
Please note that our Unix server is access through a vpn connection. With WinScp , it is possible to see the C drive and all the folders on our Unix server but Winscp is not SAS EG.
Is there a work around solution possible?
If your company has chosen to set up SAS this way through a VPN then there's likely no method to have this accomplished. This assumes you're actually using a VPN and not just a Unix Server via FTP.
It requires the SAS administrator to set up the connection and to cross the VPN which is usually set up that way for a reason.
You can create a file listing easily from your windows side and upload it though.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.