Sometimes, we need to keep the name and path of the executing program in the FOOTNOTE of the generated table or listings.
I have always created a macro variable using the %let statement and, then I called the Macro variable in the footnote statement to get the name of the program. Eventhough it is simple.. it may not be suitable when we write application which need to self document...
Here is another technique which can be used to retrieve the pathname and filename (last executed) .....
To get the last opened filename:
proc sql noprint;
select scan(xpath,-1,'\') into :progname from sashelp.vextfl
where upcase(xpath) like '%.SAS';
quit;
%put &progname;
result: filename.sas
or
data _null_;
set sashelp.vextfl(where=(upcase(xpath) like '%.SAS'));
call symput('program', scan(xpath,-1,'\'));
run;
%put &program;
result: filename.sas
To get path name ... then .. use the following code;
proc sql noprint;
select xpath into :progname
from sashelp.vextfl where upcase(xpath) like '%.SAS';
quit;
%put &progname;
Result:
H:\Company\Client\Study\ABC304\Programs\filename.sas
or
data _null_;
set sashelp.vextfl
(where=(upcase(xpath) like '%.SAS'));
call symput('program', xpath));
run;
%put &program;
Result:
H:\Company\Client\Study\ABC304\Programs\filename.sas
Here is another coolway to retrieve the filename and path of last executed program;
If you are using Windows operating system, we can access the executing program and its path using two environmental variables SAS_EXECFILENAME and SAS_EXECFILEPATH.
To access the values of these two variables use %SYSGET macro function.
The below macro calls(pathfind and filefind) gets u the name of the executing program and its path:
%macro pathfind;
%sysget(SAS_EXECFILEPATH)
%mend pathfind;
%put %pathfind;
%macro filefind;
%sysget(SAS_EXECFILENAME)
%mend filefind;
%put %filefind;
I have always created a macro variable using the %let statement and, then I called the Macro variable in the footnote statement to get the name of the program. Eventhough it is simple.. it may not be suitable when we write application which need to self document...
Here is another technique which can be used to retrieve the pathname and filename (last executed) .....
To get the last opened filename:
proc sql noprint;
select scan(xpath,-1,'\') into :progname from sashelp.vextfl
where upcase(xpath) like '%.SAS';
quit;
%put &progname;
result: filename.sas
or
data _null_;
set sashelp.vextfl(where=(upcase(xpath) like '%.SAS'));
call symput('program', scan(xpath,-1,'\'));
run;
%put &program;
result: filename.sas
To get path name ... then .. use the following code;
proc sql noprint;
select xpath into :progname
from sashelp.vextfl where upcase(xpath) like '%.SAS';
quit;
%put &progname;
Result:
H:\Company\Client\Study\ABC304\Programs\filename.sas
or
data _null_;
set sashelp.vextfl
(where=(upcase(xpath) like '%.SAS'));
call symput('program', xpath));
run;
%put &program;
Result:
H:\Company\Client\Study\ABC304\Programs\filename.sas
Here is another coolway to retrieve the filename and path of last executed program;
If you are using Windows operating system, we can access the executing program and its path using two environmental variables SAS_EXECFILENAME and SAS_EXECFILEPATH.
To access the values of these two variables use %SYSGET macro function.
The below macro calls(pathfind and filefind) gets u the name of the executing program and its path:
%macro pathfind;
%sysget(SAS_EXECFILEPATH)
%mend pathfind;
%put %pathfind;
%macro filefind;
%sysget(SAS_EXECFILENAME)
%mend filefind;
%put %filefind;