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.
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.
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.
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";
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
@Quentin: I have tried this..but its not working for me. Seems like SAS is unable to identify the windows module WNetGetConnectionA.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.