/******************* URBAN INSTITUTE MACRO LIBRARY *********************
: GetProgName
Macro: Autocall macro to return the name of the currently
Description
submitted SAS program to the global macro variable given by VAR. in interactive mode, macro returns "(Interactive)".
If running
: Open code
Use
: Peter Tatian
Author
***********************************************************************/
GetProgName( var );
%macro
/*************************** USAGE NOTES *****************************
:
SAMPLE CALLGetProgName( prog )
%
saves the name of the currently submitted SAS program to the
macro variable PROG*********************************************************************/
/*************************** UPDATE NOTES ****************************
03/02/06 Changed %sysfunc to %qsysfunc in %let index = ... line
to handle program names with special characters.*********************************************************************/
***** ***** ***** MACRO SET UP ***** ***** *****;
%
&var;
%global
%local dirchar len index ProgName;
***** ***** ***** ERROR CHECKS ***** ***** *****;
%
***** ***** ***** MACRO BODY ***** ***** *****;
%
%let FullName = %sysfunc( getoption( sysin ) );
%if &SYSSCP = WIN %then
= \;
%let dirchar %else %do;
err_mput( macro=GetProgName, msg=Operating system not supported. )
%
%goto exit;
%end;
%if %length( &FullName ) > 0 %then %do;
%let len = %length( &FullName );
%let index = %index( %qsysfunc( reverse( &FullName ) ),&dirchar );
%let ProgName = %substr( &FullName, &len - &index + 2 );
&var = &ProgName;
%let
%end;%else %do;
&var = (Interactive);
%let
%end;
:
%exit
***** ***** ***** CLEAN UP ***** ***** *****;
%
%mend GetProgName;
/************************ UNCOMMENT TO TEST ***************************
GetProgName( prog );
%=&prog;
%put prog/**********************************************************************/
Get Program Name
Purpose: Autocall macro to return the name of the currently submitted SAS program to the global macro variable given by VAR. If running in interactive mode, macro returns “(Interactive)”.