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;
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.
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;
I'm not concerned with the code in the middle. I'm concerned that the log quits working.
@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.
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 "." ?
That's not the code I'm concerned with for this question.
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".
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;
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.
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.
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;
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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.