BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cadams47
Fluorite | Level 6

 I ran some code in SAS 9.4 where I did not want to see all the errors so I turned the log off. Then I turned the log back on.

 

proc printto log=junk; run;                              *turn log off;
     data fees1 ; set fees;
          sic2=put(sich,4.);
          sic2=substr(sic2,1,find(sic2,'.')+2);
          put sich= / sic2=;
     run;
proc printto ; run;                                           *turn log back on;

 

However, when I run my next line of code (shown below just to show it's simple), I can see it creates a new dataset, but the log doesn't respond. I.e., any code I run after the code above works, but the log doesn't respond.

 

data delete; set fees; run;                          *the dataset delete gets created, but the log doesn't respond;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Your aren't trying to NEST this type of behavior are you?

If you do something like:

proc printto log=file1;
....
proc printto log=file2;
....

If you want to redirect back to FILE1 you need to do that in the next call.  if so then remember FILE1 somehow.  In a macro variable or in a dataset or some other way so that you can return the output back to FILE1 when you a done sending it to FILE2.

View solution in original post

12 REPLIES 12
Reeza
Super User

Can you show a worked example with the log? Add a basic proc means after or something?

Did you also use Option nonotes? 

 

Restart SAS and check it as well.

 


@cadams47 wrote:

 I ran some code in SAS 9.4 where I did not want to see all the errors so I turned the log off. Then I turned the log back on.

 

proc printto log=junk; run;                              *turn log off;
     data fees1 ; set fees;
          sic2=put(sich,4.);
          sic2=substr(sic2,1,find(sic2,'.')+2);
          put sich= / sic2=;
     run;
proc printto ; run;                                           *turn log back on;

 

However, when I run my next line of code (shown below just to show it's simple), I can see it creates a new dataset, but the log doesn't respond. I.e., any code I run after the code above works, but the log doesn't respond.

 

data delete; set fees; run;                          *the dataset delete gets created, but the log doesn't respond;


 

cadams47
Fluorite | Level 6

I'm not concerned with the code in the middle. I'm concerned that the log quits working.

Reeza
Super User

@cadams47 wrote:

I'm not concerned with the code in the middle. I'm concerned that the log quits working.


Yes but the code in the middle and after could be causing that. It's much easier to debug if you can provide that information. We can make guesses but not everyone is comfortable doing that, especially when it's pretty easy to provide a worked example. 

Astounding
PROC Star

How do you plan to debug the program, if you can't see all the errors?

 

The issue might be contained in this statement:

          sic2=substr(sic2,1,find(sic2,'.')+2);

 

How do you expect to find a "." in SIC2, when you assign it a value that can't possibly contain a "." ?

cadams47
Fluorite | Level 6

That's not the code I'm concerned with for this question.

ballardw
Super User

Try using to specifically just affect the log output.

 

proc printto  log=log; 
run;       

Without seeing code between the proc printto calls it is hard to guess what you may have set that might affect this behavior. Look closely for any OPTIONS, Proc Options and anything related to your destination file "junk".

Ksharp
Super User

You didn't assign a file name to log

 

 

proc printto log='c:\temp\xxx.log' ; run;                              *turn log off;
     data fees1 ; set fees;
          sic2=put(sich,4.);
          sic2=substr(sic2,1,find(sic2,'.')+2);
          put sich= / sic2=;
     run;
proc printto ; run;   

Tom
Super User Tom
Super User

First get it to work for a trivial set of code in the block that is being re-directed.

Then try adding in your actual code one logical block at a time until it stops working.  That way you can find what part of your code broke it.

Tom
Super User Tom
Super User

Your aren't trying to NEST this type of behavior are you?

If you do something like:

proc printto log=file1;
....
proc printto log=file2;
....

If you want to redirect back to FILE1 you need to do that in the next call.  if so then remember FILE1 somehow.  In a macro variable or in a dataset or some other way so that you can return the output back to FILE1 when you a done sending it to FILE2.

ErikLund_Jensen
Rhodochrosite | Level 12

Hi @Tom 

 

SAS has an automatic macro variable to help with that. Here is an example:

proc printto log='c:/temp/testlog1.log' new;
run;
%let log1 = &sysprinttolog;

%put This is first line written to log1;

proc printto log='c:/temp/testlog2.log' new;
run;
%let log2 = &sysprinttolog;

%put This is first line written to log2;

proc printto log=&log1;
run;

%put This is second line written to log1;

proc printto log=&log2;
run;

%put This is second line written to log2;

proc printto; 
run;
Tom
Super User Tom
Super User

I wonder when they added those?

 

Too bad they didn't make the default values more useful.  I would recommend adding a little logic when saving 

%let old_log = %sysfunc(ifc(%length(&sysprinttolog),&sysprinttolog,LOG));

Then you could later use the value directly.

proc printto log=&old_log; run;
ErikLund_Jensen
Rhodochrosite | Level 12
Hi Tom
A good idea!
Sysprinttolog and Sysprinttolist are new in 9.4, or maybe first official and documented in 9.4. They might have been there for a long time like the Monotonic function, which has been there at least since 9.1, but as far as I know is still undocumented.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 12 replies
  • 6538 views
  • 0 likes
  • 7 in conversation