I have been trying to put some code together as as standard macro to be included in all programs which are run. The code I am pulling together is essentially a complex proc printto with some automated checking built in to identify errors.
Is it running in a project environment with standard folder structures, but I was wondering if there is a macro variable which details your program name and/or the directory it is stored in (or a way to get this data). This would allow me to amend the code so that it would automatically save off without having to populate the macro with a folder and filename.
I hope this is clear enough and nay help would be greatly appreciated.
OK Ian, no batch, then SYSPROCESSNAME is useless.
If your running in a interactive session, try looking into the DICTIONARY.EXTFILES table, that lists all external files opened in your session (including your scripts).
Your script should be listed there, you only have to find a logical manner to pick the right entry.
_data null_'s tip seems also a good solution, you should give it a try.
> Thanks for the info, I have already looked at the
> automatic macro variables by running a %put _all_;
> and it never returned any value which looked
> I am running PC SAS locally on a windows environment,
> so I am not running it in a batch process.
you're building a significant challenge, attempting to trap the names of "programs which are run". In the ad-hoc job submission worlds I have seen, the included program is often updated before it is "run", and in some cases the standard operating practises recommend not saving.
You may find a convenient trap available when code is submitted. Function keys and toolbar icons can be adapted to preform the trap you need.
You refer to proc printto. Have you recognised the potential of the alternative ALTLOG/ALTPRINT options? These leave your normal log and listing but send an additional copy to a file. Dynamically, you can identify and work with that file (but beware file locks which only a few applications like notepad.exe will ignore).
What would you want to do with the errors in a log which results from code which has not been saved and was created from new? No SAS feature can provide a name, because no name has been associated with that program!