02-05-2016 02:25 AM
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.
02-05-2016 02:39 AM
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.
02-05-2016 03:05 AM
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.
02-05-2016 03:37 AM
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";
02-05-2016 06:12 AM
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
02-09-2016 02:01 AM
@Quentin: I have tried this..but its not working for me. Seems like SAS is unable to identify the windows module WNetGetConnectionA.