Published on :

Listing System Drives via DRIVEMAP

This code is also available in: Deutsch Español Français
Awaiting validation
Attention : This code requires administrator privileges.
The code uses the FILENAME statement with the 'drivemap' option to assign a reference to the system's mapped drives. A DATA step then reads this reference to display the drive letters in the log. Important note: The 'drivemap' functionality is historically tied to Windows environments and may not work as expected in a SAS© Viya environment under Linux.
Data Analysis

Type : EXTERNAL


Data is dynamically extracted from the operating system via the 'drivemap' device.

1 Code Block
DATA STEP Data
Explanation :
Allocates the 'drivemap' system file to the 'd' reference, reads entries (drive letters) via INFILE, and displays them in the log via PUT.
Copied!
1filename d drivemap ;
2DATA ;
3 INFILE d ;
4 INPUT drive $2. ;
5 put drive= ;
6RUN ;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Banner
Expert Advice
Expert
Stéphanie
Spécialiste Machine Learning et IA.
« The DRIVEMAP engine within the FILENAME statement is an elegant, often underutilized method for allowing SAS to query the host's storage infrastructure directly. By transforming the list of local and network-mapped drives into a readable data stream, you enable your programs to adapt dynamically to the network environment without hardcoding drive letters. »