How to list your mapped drives in a SAS program

This post was kindly contributed by The SAS Dummy - go there to comment and to read the full post.

If you work in a team environment, you might be accustomed to using mapped network drives for source data folders or to publish results. If you’ve recently moved to a SAS server environment, you might not have those mapped drives available. How can you tell?

This question was posted on the SAS Support Communities, and SAS Communities member Patrick provided a handy code snippet that does the trick. Patrick learned the trick himself from SAS Note 24818.

The following code uses a special DRIVEMAP device for the FILENAME statement. DRIVEMAP works only on Windows systems, which are the only systems that support the concept of mapped drives.

filename diskinfo DRIVEMAP;
data _null_;
  infile diskinfo;
  input;
  put _infile_;
run;

Here’s the output on my PC, where I have a two mapped network drives, U: and W:. (C: and D: are part of my laptop device.)

NOTE: The infile DISKINFO is:
      Drivemap Access Device,
      PROCESS,RECFM=V,LRECL=32767
C:
D:
U:
W:

Mapped drives are typically available only from your local machine. Even if you use SAS on a remote Windows server, the process that defines the mapped drive aliases is usually not triggered when you connect. If this is the case for you, you’ll have to adjust your process to use UNC path notation (example: “\\server\folder\project” instead of the familiar “P:\project” shortcut). (Additional note for SAS admins: on a Windows SAS server, you must mark the server machine as Trusted for Delegation to allow end users to access these network paths.)

If you’ve moved from a local PC version of SAS to a remote non-Windows server (these days, Linux is common), then I’m afraid that “mapped drives” are a lost concept. You’ll need to change your code to use Unix-style paths. A SAS admin or Unix-admin might need to help you to find the correct locations.

The post How to list your mapped drives in a SAS program appeared first on The SAS Dummy.

This post was kindly contributed by The SAS Dummy - go there to comment and to read the full post.