/******************* URBAN INSTITUTE MACRO LIBRARY *********************
: GetProgDrive
Macro: Autocall macro to return the drive letter of the currently
Description
submitted SAS program to the global macro variable given by VAR. in interactive mode, macro returns blank.
If running
: Function
Use
: Peter Tatian
Author
***********************************************************************/
GetProgDrive( var );
%macro
/*************************** USAGE NOTES *****************************
:
SAMPLE CALLGetProgDrive( _pdrive )
%
saves drive letter of current program to macro var _pdrive*********************************************************************/
/*************************** UPDATE NOTES ****************************
7/28/15 Program created
9/23/20 Modified to return the computer name for network pathnames.
: Return "\\SAS1" for pathname "\\sas1\DCData\Libraries".
Example*********************************************************************/
***** ***** ***** MACRO SET UP ***** ***** *****;
%
&var;
%global
%local FullName;
***** ***** ***** ERROR CHECKS ***** ***** *****;
%
***** ***** ***** MACRO BODY ***** ***** *****;
%
%let FullName = %sysfunc( getoption( sysin ) );
%if %length( &FullName ) > 1 %then %do;
%if %substr( &FullName, 1, 2 ) = \\ %then %do;
%let &var = %upcase(%substr( &Fullname, 1, %index( %substr( &Fullname, 3 ), \ ) + 1 ));
%end;%else %do;
%let &var = %upcase(%substr( &FullName, 1, 1 ));
%end;
%end;%else %do;
&var = ;
%let
%end;
***** ***** ***** CLEAN UP ***** ***** *****;
%
%mend GetProgDrive;
/************************ UNCOMMENT TO TEST ***************************
GetProgDrive( _pdrive )
%
%put _user_;/**********************************************************************/
Get the Drive Letter of the Program
Purpose: Autocall macro to return the drive letter of the currently submitted SAS program to the global macro variable given by VAR. If running in interactive mode, macro returns blank.