Date: Tue, 20 Apr 1999 10:09:52 -0400
Reply-To: "Ward, David" <dward@INNOVEX-DAS.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: "Ward, David" <dward@INNOVEX-DAS.COM>
Subject: Re: Unfinished SAS-L Live from Miami Beach business
Content-Type: text/plain
Having not attended the Miami Beach Live SAS-L (though I was present
in Miami), I'm a little hesitant to reply to a message with such a subject,
but I thought you might like to see a relevant and very useful macro ...
Since a few postings along this thread have shown useful macros to
build footnotes, consider this one, a macro function (that's what I call
macros that resolve a desired value) that returns the current program loaded
in the program editor (well, let's say 9/10 times). The macro reads the
view sashelp.vextfl, which contains information about the most recently
accessed files. The first record is almost always your program, whether it
is loaded in the program editor or called by a %include.
%macro currprog;
/** OPEN SASHELP VIEW VEXTFL WHICH CONTAINS EXTERNAL FILES
ACCESSED **/
%let dsid=%sysfunc(open(sashelp.vextfl));
%let rc=%sysfunc(fetch(&dsid));
%local currprog;
%tryagain:
/** MOVE THROUGH EACH RECORD LOOKING FOR A VALID SAS PROGRAM **/
/** EXCLUDE SASAUTOS, AUTOEXEC, SASMSG FILES **/
%if %sysfunc(getvarc(&dsid,1))^=%sysfunc(getoption(sasautos)) and
%quote(%sysfunc(getvarc(&dsid,2)))^=%quote(%sysfunc(getoption(autoexec)))
and
%index(%upcase(%quote(%sysfunc(getvarc(&dsid,2)))),SASMSG)=0
%then
%let currprog=%sysfunc(getvarc(&dsid,2));
%else %do;
%let rc=%sysfunc(fetch(&dsid));
%if %quote(&currprog)= and &rc=0 %then %goto tryagain;
%end;
%let rc=%sysfunc(close(&dsid));
/** PUT OUT THE CURRENT PROGRAM IF FOUND **/
&currprog
%mend currprog;
I have been using this for over a year in standard footnotes to
return the program name.
- D. Ward
|