BookmarkSubscribeRSS Feed
Aditi24
Obsidian | Level 7

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.

5 REPLIES 5
SASKiwi
PROC Star

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.

Aditi24
Obsidian | Level 7

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.

 

SASKiwi
PROC Star

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";

Quentin
Super User

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

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Aditi24
Obsidian | Level 7

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 3122 views
  • 2 likes
  • 3 in conversation