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

Good Morning,

I'm looking almost all day how to copy sas log into a text file, but without erasing it into sas (no proc printto, or maybe if some option exists…)

I need this code to be inside my sas program and not executed into linuy command line (or of course in a linux command line into my sas program)

I would like to be in my sas enterprise guide session, run my project (or program) and then see the logs into sas, but also save them (automatically) in a text file.

I saw on internet the altlog option, but I didn't manage to make it work...

Hope somebody could help me.

Thank you,
Sabrina


1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11

Code Direct Log to the External Log file , Reads and displays the external file and displays it in the Log Window in the same session. Let me know if this works.

 

/* Specify the path for the external log */

*Specify the Path;
%let path=<Your_Path>/sample.log;
 
* Export Log to Extrenal Path;
proc printto log="&path.";
run;
 
*Specify Your SAS Code Here;
data Sample;
   set sashelp.class;
run;
 
proc print data=Sample;
run;
 
proc printto log=log; run;
 
*Read the Log from the External file and Display in the Log Window;
data _null_;
   infile "&path.";
   input;
   putlog ">" _infile_;
run;

View solution in original post

6 REPLIES 6
Sabrina3
Fluorite | Level 6
Thank you Reeza for your help…
I cannot manage to make the altlog work… If I understood it correctly, sas must be triggered in batch right ?

I'm looking for a solution that can be written in the sas script.
Quentin
Super User
It would be sooo nice if altlog could be specified in SAS code rather than only during SAS session start-up. Feel free to up-vote my ballot suggestion for this feature: https://communities.sas.com/t5/SASware-Ballot-Ideas/Allow-ALTLOG-to-be-specified-on-OPTIONS-statemen...
BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
r_behata
Barite | Level 11

Code Direct Log to the External Log file , Reads and displays the external file and displays it in the Log Window in the same session. Let me know if this works.

 

/* Specify the path for the external log */

*Specify the Path;
%let path=<Your_Path>/sample.log;
 
* Export Log to Extrenal Path;
proc printto log="&path.";
run;
 
*Specify Your SAS Code Here;
data Sample;
   set sashelp.class;
run;
 
proc print data=Sample;
run;
 
proc printto log=log; run;
 
*Read the Log from the External file and Display in the Log Window;
data _null_;
   infile "&path.";
   input;
   putlog ">" _infile_;
run;
Sabrina3
Fluorite | Level 6

Thank you r_behata,

It's a good idea, but doing like this we lose the fonctionality of seen the errors and warning in the bottom bar.
See the picture below
Capture.PNG

 
Sabrina3
Fluorite | Level 6
If I remove the ">" and just write the last line :
putlog _infile_;

it works !

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 6 replies
  • 6329 views
  • 5 likes
  • 4 in conversation