DATA Step, Macro, Functions and more

Unable to resolve UNC path of mapped drive while browsing files

Reply
Contributor
Posts: 71

Unable to resolve UNC path of mapped drive while browsing files

Hi,

 

I have a small utility coded in SAS which is used to open and modify SAS files as per the needs of programmer. These SAS files are present on a network drive which could also be mapped to the local drive. The problem I am facing is, the UNC path of selected SAS file doesnt resolve but instead drive letter comes up in the absolute path of the file.

For eg. If I've mapped \\mrllogon\system\phases\tools to drive W, I am getting path as W:\adhoc\programming instead of \\mrllogon\system\phases\tools\adhoc\programming.

Please suggest a method to resolve this drive paths in Base SAS.

Super User
Posts: 3,260

Re: Unable to resolve UNC path of mapped drive while browsing files

Where is Base SAS running? On your PC or on a remote server? If SAS is running on a remote server then the UNC path must be available there not on your PC.

 

If SAS is running on your PC try the UNC path not the mapped drive first in Windows Explorer. If it works it will also work in SAS.

Contributor
Posts: 71

Re: Unable to resolve UNC path of mapped drive while browsing files

Hi @SASKiwi,

I am using PC SAS and I want my code to resolve the UNC path so that I can get the correct absoulte path of the file location to store in my database.

 

Super User
Posts: 3,260

Re: Unable to resolve UNC path of mapped drive while browsing files

In that case you should be able to assign the UNC directly like this, as long as it also works in Windows Explorer:

 

libname MyLib "\\mrllogon\system\phases\tools";

PROC Star
Posts: 1,324

Re: Unable to resolve UNC path of mapped drive while browsing files

How are you getting the file path of the file?

 

4    filename a "X:\Junk\a.txt";
5    filename b "\\myservser\Quentin\Junk\a.txt";
6
7    %put %sysfunc(pathname(a));
X:\Junk\a.txt
8    %put %sysfunc(pathname(b));
\\myservser\Quentin\Junk\a.txt

In my experience, pathname() will return a UNC if the fileref/libref was assigned with a UNC.  But if you have a fileref that was assigned with a mapped letter drive, and you want to convert that to a UNC, I don't know how to do it.

 

 

[Pause for Googling]

 

Looks like Art Carpenter knows how to do it.  See %GetUNC in this paper: http://www2.sas.com/proceedings/forum2008/023-2008.pdf

Contributor
Posts: 71

Re: Unable to resolve UNC path of mapped drive while browsing files

@Quentin: I have tried this..but its not working for me. Seems like SAS is unable to identify the windows module WNetGetConnectionA. 

Ask a Question
Discussion stats
  • 5 replies
  • 359 views
  • 2 likes
  • 3 in conversation