I'm sure this has been a topic of discussion for other users, but the search function on this site sucks. A search for SAS EG log returns everything with SAS, everything with a capital E, everything with a capital G, and everything with log). Adding quotes or other Boolean operators doesn't help.
Anyway, I've used base SAS for years, but I'm a relatively new user of SAS EG. I want to see the log, updated in real time, as the code runs, in case there are errors or warnings. That way I can fix them instead of waiting minutes or hours to find out there was an error. This is the default behavior for both base and EG.
However, there are also times when I want the log to save automatically after the code completes. I want to use a macro variable so that the program name and version are automatically added to the log file name. This is trivial in base SAS. It simply requires adding a line of code at the end of the program: /*Save log*/
dm "log; file ""path/logs/&progname.V&version..log"" replace;";
This is no longer supported in SAS EG, and no replacement for this behavior has been added. But what REALLY pisses me off is that no error or warning is displayed in the log to indicate that the dm statement was not executed! I ran several programs, thinking that the logs were being saved, only to find out they're gone forever. The data is occasionally updated, so I can't recreate them.
Why was such a basic function from base SAS dropped in the "more advanced" SAS EG? That's like buying a luxury car and finding out it doesn't have windshield wipers 🙄 And having to manually name and save the log file is like the dealer telling u that u can just stick your hand out of the window and use a squeegee to clean the windshield as u drive.
Hi @Wolverine ,
DM commands are for Display Manager, the windowing environment of SAS that most people experience as "PC SAS". DM commands do not function in an SAS runtime environment that isn't Display Manager. For example, if you were to run your program in batch SAS:
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin c:\temp\logtest.sas
Your log file would also not be saved/refreshed.
To focus on the spirit of the question: is there a way to automatically save a log in EG? Yes. For any task/program, you can export the SAS log as a step:
This allows you to specify a place and option to overwrite an existing file.
Remember that EG also supports the Project Log, which allows you to aggregate and export log content from an entire flow or project.
To focus on the spirit of the question: is there a way to automatically save a log in EG? Yes. For any task/program, you can export the SAS log as a step
That's still not a great solution, because it takes longer to set up the Project than it does to manually save the log. And is there a way to use macro variable from the program to automatically generate the filename of the log file?
In the SAS EG log window, the user can go to Share/Log/Export, and then choose the destination path and change the filename of the log file. Would it really be that difficult to add a command to SAS EG that could perform these steps (that the GUI is already capable of doing!) based on a line or two of code, just like base SAS can do? I realize that SAS EG doesn't use Display Manager, but it seems like it would be almost trivial to add a substitute command that is at least capable of saving logs.
@Wolverine - I get the impression you are using EG for both running Production jobs where you want to keep SAS logs and also for program development and analytics. If this is the case then an alternative approach could be to move the running of your Production jobs to SAS Management Console. Not only can they be automated with Schedule Manager, SAS logs are produced and saved automatically. Not only that you can trigger automatic emails if the jobs fail so you only need to look at SAS logs if you get an email. We use this approach and it works a treat.
If you have access to SAS from a Linux terminal (I see you're using forward slashes), write and submit your programs from there and never look at a GUI again. Logs will be saved automatically as a bonus.
>>> I want to see the log, updated in real time, as the code runs, in case there are errors or warnings. That way I can fix them instead of waiting minutes or hours to find out there was an error. <<<
EG updates the log after each step boundary (data, proc, etc.), so, if your program has several steps then the log will update after each step completes.
Also, if your EG project has several SAS programs then you can specify the action to take when an error occurs potentially saving you a lot of time.
To do this, right-click on a program node to choose Properties, then click Code Submission, then click Customize Code Submission Options, then for Action to take on Error in the execution of this program select, for example, Stop all items.
Regards,
Bill
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.