DATA Step, Macro, Functions and more

SAS log cut off the first 95 lines of code

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

SAS log cut off the first 95 lines of code

Hello, we've just upgraded to SAS v9.04.01 on windows 7.  The programs I run created a log file and also output the executed codes to the log window for QC.  Since the upgrade, sometimes the log doesn't display the first 95 lines of executed codes.  Could someone please help?  Thanks.


Accepted Solutions
Solution
‎07-20-2017 10:58 AM
Occasional Contributor
Posts: 10

Re: SAS log cut off the first 95 lines of code

Hi Shmuel, ballardw, and Tom,

 

I think I figured out what was causing the issue.  After Shmuel suggested maybe the log was still held by the previous script/session/OS, I started checking for consistency uses of the last DM statement on the scripts.  I found that some of the DM statement at the end of some of the scripts were modified by one of the analysts using

 

dm log 'print file = "K:\...\&mfolder\&measure.-Historic Data Run &memschema..log" replace' LOG;

 

instead of

 

dm 'log; file "K:\...\&mfolder\&measure.-Historic Data Run &memschema..log" replace';

 

Also, they didn't put the ods pdf close statement at the end of the script.  So, when I submitted this one, it was okay until the subsequent scripts were submitted then the issue occurred.  That's why it seemed so random.

 

I made the fix using the DM 'log; file ....log" replace'; and haven't seen the issue since.

 

Thank you all for taking the time to try helping me.

View solution in original post


All Replies
Super User
Posts: 10,538

Re: SAS log cut off the first 95 lines of code

It would likely help to show 1) the code that generates the issue and 2) a log from running that code.

Occasional Contributor
Posts: 10

Re: SAS log cut off the first 95 lines of code

Hi ballardw, I've attached the script & log for your references.  The strange thing this issue occur at random.

Attachment
Super User
Super User
Posts: 6,502

Re: SAS log cut off the first 95 lines of code

[ Edited ]

If you want to have a clean SAS log file then 

  1. Remove the DM commands from the program(s).
  2. Submit the job from the command line (batch mode) instead of running it interactively.

If you want help with debugging why the log was cleared provide the code for at least these six macros that your program is calling. Perhaps they also have DM commands in them.

%Today;   /* set up macro variable (today) that contains the current date */
%Start_Time;   /* capture date time start of program initiation */
%Locking_Log(measure=APC,run=NUM);  /* check for prior run in HDMPRD */
...
%PPO_STATE(memtable=Member_Elig,measure=APC,excl_rsns=NONE);
...
%med_prime(memtable=Member_Elig,measure=APC,excl_rsns=NONE);
...
%hospice(memtable=Member_Elig,measure=APC,excl_rsns=NONE);

 If you want to step through the program then open it use the PGM (old style editor) instead of the Enhanced Editor. Then turn on the line numbers (if not already one).  The submit the program step by step using the SUBTOP command add see which lines of code are clearing the log.  

 

So for the example program you could start with SUBTOP 26 to get the macro variables and options defined. Then you could use SUBTOP 2 to run the first macro call.  etc.

 

 

 

Occasional Contributor
Posts: 10

Re: SAS log cut off the first 95 lines of code

Hi Tom, I checked all of those macros and none of them use a DM statement.
Super User
Super User
Posts: 6,502

Re: SAS log cut off the first 95 lines of code


jtran001 wrote:
Hi Tom, I checked all of those macros and none of them use a DM statement.

Does it consistently generate logs without the beginning? Is it always missing the same part?

As I said before if you really want to produce complete logs then do not run the programs interactively.

Try debugging by running step by step and examining the log window as you go to see if it is getting cleared.

Is it that the SAS log window has the full log, but the file that the DM command generates is missing the beginning?

Solution
‎07-20-2017 10:58 AM
Occasional Contributor
Posts: 10

Re: SAS log cut off the first 95 lines of code

Hi Shmuel, ballardw, and Tom,

 

I think I figured out what was causing the issue.  After Shmuel suggested maybe the log was still held by the previous script/session/OS, I started checking for consistency uses of the last DM statement on the scripts.  I found that some of the DM statement at the end of some of the scripts were modified by one of the analysts using

 

dm log 'print file = "K:\...\&mfolder\&measure.-Historic Data Run &memschema..log" replace' LOG;

 

instead of

 

dm 'log; file "K:\...\&mfolder\&measure.-Historic Data Run &memschema..log" replace';

 

Also, they didn't put the ods pdf close statement at the end of the script.  So, when I submitted this one, it was okay until the subsequent scripts were submitted then the issue occurred.  That's why it seemed so random.

 

I made the fix using the DM 'log; file ....log" replace'; and haven't seen the issue since.

 

Thank you all for taking the time to try helping me.

Trusted Advisor
Posts: 1,401

Re: SAS log cut off the first 95 lines of code

It is difficult to wnow without having the running code.

I suppose you have OPTIONS NOSOURCE at the begining of the code and somewhere later,

just before the code displayed in the log, there is: OPTIONS SOURCE.

 

Other possibility is using PROC PRINTTO LOG=... - in order to write the log to a file, and later

closing it with PROC PRINTTO; RUN;

 

If those are not the cases, please post full code and the full log of that code run.

 

 

Occasional Contributor
Posts: 10

Re: SAS log cut off the first 95 lines of code

Hi Shmuel, ballardw asked for the same thing as you.  I attached a script and log in my response to ballardw.  Would you please check them out there?  Thank you.

Trusted Advisor
Posts: 1,401

Re: SAS log cut off the first 95 lines of code

I haven't find in your log, neither NOSOURCE nor PRINTTO strings,

but there are DM statements relation to LOG (lines 1, 574);

 

Are you running scripts in a chain? do you have the issue running a script as first action entering SAS session?

Maybe the issue is the result of previous running code - the 95 absent lines are written to the previous code log ?

 

On log line 574 you have:

dm log 'file "K:\HSE\HEDIS\&rptyr\documentation\measures\A P C\APC Numerator &memschema..log" 
        replace' log;

that makes me suspicious. Try to run the code without it or move it to the beginning.

Occasional Contributor
Posts: 10

Re: SAS log cut off the first 95 lines of code

Hi Shmuel - This issue occurs recently since the SAS v9.4 upgrade. The dm log on line 574 you cited had always been in the script. The one that's new is the DM statement at the top.

I submitted the scripts one after another in multiple SAS sessions. When one finished, I closed that session, started a new one to submit a new script. The issue happens at random. Sometimes I don't have the issue running a script as the very first one in a first SAS session. Sometime I do like now.
Trusted Advisor
Posts: 1,401

Re: SAS log cut off the first 95 lines of code

Do you have different/unique log file names on each script?

Can it be that you are trying to write to a logfile that occasionally is still held by previous script/session/OS ?

Occasional Contributor
Posts: 10

Re: SAS log cut off the first 95 lines of code

Hi Shmuel - yes, I do have unique log file names on each script. If the issue is caused by being help by previous script/session, then is there a way to release it?

I rebooted my computer this morning, opened a new SAS session, removed the DM line at the top, submitted only one script; but the issue still occur.
Trusted Advisor
Posts: 1,401

Re: SAS log cut off the first 95 lines of code

Closing sas session should close all files open. Sometimes the OS is busy and thre is a delay in relaesing a file.

 

I have no more ideas and hope someone else will have.

Occasional Contributor
Posts: 10

Re: SAS log cut off the first 95 lines of code

Thank you Shmuel for trying.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 19 replies
  • 144 views
  • 0 likes
  • 4 in conversation