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 (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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