LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 25 Apr 2007 17:36:24 -0400
Reply-To:   Don Henderson <donaldjhenderson@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
Comments:   RFC822 error: <W> MESSAGE-ID field duplicated. Last occurrence was retained.
From:   Don Henderson <donaldjhenderson@HOTMAIL.COM>
Subject:   Re: delaying macro execution until runtime of a procedure
In-Reply-To:   <403593359CA56C4CAE1F8F4F00DCFE7D064C6A6D@MAILBE2.westat.com>
Content-Type:   text/plain; charset="us-ascii"

If the program is indeed being run interactively, that means that the user can include a new program at any point in time. I presume that you would want the program name to be updated to reflect that.

There is no way that I am aware of that would automatically update an already existing footnote to reflect the new value of a macro variable or system variable. Since macro is a code generator, the value will be resolved when the footnote statement is encountered and the value will be resolved then. Once the footnote statement has been parsed, there is no way (that I know of) to have it automagically be updated other than repeating the footnote statement.

The macro is not called again when you run a proc that uses a previously defined footnote statement.

You might look to see if there is a way to do this with a custom ODS template that could perhaps reference the variable. However, I am not sure if/how that would work. I would have to defer that to a template guru.

HTH, -don h

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Michael Raithel Sent: Wednesday, April 25, 2007 3:48 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: delaying macro execution until runtime of a procedure

Dear SAS-L-ers,

Evan Davies posted the following:

> I am setting up an office-wide autoexec.sas file that has a macro > called %prog_pathname in it that resolves to the path and name of the > program thatis running interactively. (The macro was written by Steve > James spj1@cdc.gov, and is in the sas-l archives for Aug 4, 2006. It > makes use of the SAS_EXECFILEPATH system var.) > > If I put footnote "This program is: %prog_pathname "; > in any procedure step in an interactive job session, the macro is > executed correctly and the path and name of the executing program is > printed in the footnote. > > But I would like to put the footnote statement into the > autoexec.sas file as well, so that my fellow officeworkers and I do > not have to code the footnote statement into every proc step that we > write. This would also insure that the true path and program are > named. We currently use %let declaration statements for the path and > program name, and after a program is passed around the office a few > times, we sometimes get sloppy and forget to change the %let statement > to the newly modified path or program revision name. Having the > footnote statement execute automatically would prevent this. > > But putting the footnote statement containing the macro into the > autoexec.sas file (after the macro definition) results in it being > executed immediately and the macro resolves to a blank, since at the > time of the execution it is in the autoexec.sas file and nothing has > been loaded to the SAS_EXECFILEPATH system variable. > > Can anybody tell me how to delay the execution of the macro in the > footnote statement until it is called in the runtime execution of the > program's proc statements? I realize that since the footnote statement > is merely "implied" or "associated" with any proc that can use a > footnote statement, if it is not explicitly coded in the proc step, > this may be problematic. But has anyone implemented an automatic path > and file footnote solution using this appproach? >

Evan, I have an untested suggestion that may be just what you need. Check out the INITSTMT option. It is specified in the SAS config file and executes after the autoexec, but before the SAS program, itself. This may or may not work, but it is worth a looksee.

Here is a link to where you could find it in the SAS Online Documentation:

http://support.sas.com/onlinedoc/912/getDoc/lrdict.hlp/a000279123.htm#a0 02445728

Let us know if it is still too early in the SAS initialization process to be able to capture the program path. (If it does not, then I think that the obtrusive %INCLUDE is your only other option).

Evan, best of luck to you in getting your program path footnote into your SAS programs!

I hope that this suggestion proves helpful now, and in the future!

Of course, all of these opinions and insights are my own, and do not reflect those of my organization or my associates. All SAS code and/or methodologies specified in this posting are for illustrative purposes only and no warranty is stated or implied as to their accuracy or applicability. People deciding to use information in this posting do so at their own risk.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Michael A. Raithel "The man who wrote the book on performance" E-mail: MichaelRaithel@westat.com

Author: Tuning SAS Applications in the MVS Environment

Author: Tuning SAS Applications in the OS/390 and z/OS Environments, Second Edition http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=58172

Author: The Complete Guide to SAS Indexes http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=60409

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Man is the only animal who laughs and has a state legislature. - Samuel Butler +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Back to: Top of message | Previous page | Main SAS-L page