Use a Windows share in a Libname statement with SAS

3.3k views Asked by At

When running SAS through EGuide locally I can successfully declare a libname as follows:

libname winlib '\\pc\folder\';

When using a SAS server this is not possible and I have to resort to using a Copy Files task.

For interest:
I believe this is because of the fact that the SAS server is Unix, is this correct?

What I've tried:
libname test '//pc/folder/'
libname test2 'smb://pc/folder/'

The other options I can think of is mounting the drive to the SAS server, this isn't viable for me as this is for ad-hoc cases.

The question:
How would I correctly declare a libname to \\pc\folder for the SAS server?

A few notes:
I cannot run locally as I have to connect to a few DBs, and I don't want to use a PROC UPLOAD or DOWNLOAD for this.

2

There are 2 answers

1
Johnathan Jacobs On BEST ANSWER

Unfortunately there is no way to do this in the manner I wish (directly using the remote path in the libname statement in a Unix environment).

You should be able to do this with a Windows SAS server and can do it with the local windows SAS server.

This is due to how Unix works, meaning one would have to mount the share.

That isn't feasible as an ad-hoc method.
I do wish Unix had a more direct way of accessing remote directories.

That being said, alternatively one can do one of the following:

  • write the data to a server-local directory, even work or home. Then Copy the data to a local directory. (by using Copy Files task in Enterprise Guide for example, or copying them manually if you have access to the location from your local PC)
  • Do the SAS processing locally and fetch the needed data over the network (this isn't feasible if you need DB access, which can't be done on the local server)
  • Get whoever is in charge of your SAS server's to set up a mount that's accessible from both your machine and the SAS server.
  • Use SAS PC files Server to accomplish this for M$ office files.
  • Setup an FTP server on your local machine and use a filename with the FTP option to read/write to it. see How do I read raw data via FTP in SAS? for an idea.

Thanks to @Tom for the suggestions.

4
Tom On

If you want SAS to read a directory then the SAS process needs to be able to see the directory.

What most companies do is create a shared directory that can be mounted by both the SAS machine and your PC then you can reference the files directly from both, just using different paths.

Otherwise if you want SAS to use a file that EG can see but SAS cannot then I suggest asking EG to upload the file. There are custom tasks available for EG to upload binary files.

Another method would be to create SAS code to connect to a machine that can see the files and pull the files over. Perhaps using FTP or SFTP protocol.