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

Hi,

 

Problem:

We are changing from using the tcp_tso script to gain access to the Mainframe, to using SAS Spawners on the Mainframe. Using option NLSCOMPATMODE when logging onto SAS on the Mainframe presents a WARNING: message. This message will break jobs run via LSF as the rc is 1.

 

Potential solution:
A centralised macro is being written to provide all SAS users with a common logon method. To hide the WARNING: message, the macro redirects the log file temporarily while the logon to the Mainframe takes place. The log is then closed, ingested into a dataset and any ERROR: or WARNING: message is reported to the user.

 

Problem with solution:

The user may have already redirected their log with proc printto. When my macro stops redirecting the log for its own purpose, the log then returns to (in EGuide) the interactive log window, rather than the users redirected log.

 

Example code:

 

proc printto log="/user/redirected/log.log" new; run;
/* This writes to the users redirected log correctly */
%put I am writing to the log.;
/* When my macro runs, it redirects the log once more, and upon signon completion, closes that log */ %MyMacro; /* This returns to the EGuide log rather than "/user/redirected/log.log" */ %put I am writing to the log again.;

 

Here's the redirect start and end code from my macro:

%let workdir=%qsysfunc(dequote(&SASWORKLOCATION));
filename lf "&workdir.mf_connect.log";
proc printto log=lf new; run;

/*...lots of code here...*/

/*	Release the log so we can ingest it.	*/
proc printto log=log; run;

Am I doing something wrong with the way I end my redirection - such as missing an option that would not force the log back to the 'default' and instead return to the user redirected log?

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

Hi,

 

How about first checking if the log is already redirected?

 

%local localLog;
%let localLog = %superq(SYSPRINTTOLOG); 

%let workdir=%qsysfunc(dequote(&SASWORKLOCATION));
filename lf "&workdir.mf_connect.log";
proc printto log=lf new; run;

/*...lots of code here...*/

/*	Release the log so we can ingest it.	*/
%if %bquote(&localLog.)= %then %do;
proc printto log=log; run;
%end;
%else %do;
proc printto log=&localLog.; run;
%end;

 

All the best

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

2 REPLIES 2
yabwon
Onyx | Level 15

Hi,

 

How about first checking if the log is already redirected?

 

%local localLog;
%let localLog = %superq(SYSPRINTTOLOG); 

%let workdir=%qsysfunc(dequote(&SASWORKLOCATION));
filename lf "&workdir.mf_connect.log";
proc printto log=lf new; run;

/*...lots of code here...*/

/*	Release the log so we can ingest it.	*/
%if %bquote(&localLog.)= %then %do;
proc printto log=log; run;
%end;
%else %do;
proc printto log=&localLog.; run;
%end;

 

All the best

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



_Dan_
Quartz | Level 8
That had crossed my mind and I was probably one Google search away from looking for %superq(SYSPRINTTOLOG).

Thanks for the tip, I'll give it a try.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 642 views
  • 0 likes
  • 2 in conversation