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

Can listings output be redirected to the log?  Using batch mode, without redirecting the log to another file, without passing arguments to SAS regarding current directory or command line arguments to mimic normal batch mode log file placement .

1 ACCEPTED SOLUTION

Accepted Solutions
PhilC
Rhodochrosite | Level 12

Ok Reeza, yes.  Because you asked that question like that, made me think outside the box, so then I just went and solved my own problem.  Thanks for the inspiration.

 

SAS Code:

PROC SQL outobs=1 noprint;
   SELECT t1.fileref
     INTO :LOG_FILEREF
     FROM SASHELP.VEXTFL t1
       where t1.xpath like '%.log%';
QUIT;

%put NOTE: LOG_FILEREF=&LOG_FILEREF;

proc printto print=&LOG_FILEREF; run;

proc print data=SASHELP.cars (obs=3);
  var _ALL_;
run;

PROC SQL;
   SELECT t1.fileref, 
          t1.xpath, 
          t1.xengine, 
          t1.modate
      FROM SASHELP.VEXTFL t1;
QUIT;

Producing output log:

 

NOTE: AUTOEXEC processing completed.

 

1          PROC SQL outobs=1 noprint;
2             SELECT t1.fileref
3               INTO :LOG_FILEREF
4               FROM SASHELP.VEXTFL t1
5                 where t1.xpath like '%.log%';
6          QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds
     

SYMBOLGEN:  Macro variable LOG_FILEREF resolves to #LN00003
7         
8          %put NOTE: LOG_FILEREF=&LOG_FILEREF;
3                                         The SAS System           14:45 Monday, November 13, 2017

NOTE: LOG_FILEREF=#LN00003
9         
10         proc printto print=&LOG_FILEREF; run;
SYMBOLGEN:  Macro variable LOG_FILEREF resolves to #LN00003

NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
     

11        
12         proc print data=SASHELP.cars (obs=3);
13           var _ALL_;
14         run;

                                          The SAS System       14:45 Monday, November 13, 2017   1

                                                                               M
                                           D                      E     H      P
                                           r                      n  C  o      G       W
                                           i                      g  y  r   M  _       h
                                           v                I     i  l  s   P  H       e
                                     O     e                n     n  i  e   G  i   W   e   L
                     M               r     T                v     e  n  p   _  g   e   l   e
           M         o          T    i     r       M        o     S  d  o   C  h   i   b   n
      O    a         d          y    g     a       S        i     i  e  w   i  w   g   a   g
      b    k         e          p    i     i       R        c     z  r  e   t  a   h   s   t
      s    e         l          e    n     n       P        e     e  s  r   y  y   t   e   h

       1 Acura MDX            SUV   Asia All    $36,945  $33,337 3.5 6 265 17 23 4451 106 189
       2 Acura RSX Type S 2dr Sedan Asia Front  $23,820  $21,761 2.0 4 200 24 31 2778 101 172
       3 Acura TSX 4dr        Sedan Asia Front  $26,990  $24,647 2.4 4 200 22 29 3230 105 183
 
 [...spaces...] 

NOTE: There were 3 observations read from the data set SASHELP.CARS.
NOTE: The PROCEDURE PRINT printed page 1.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
     

15        
16         *proc printto log=&LOG_FILEREF; run;
17        
18         PROC SQL;
19            SELECT t1.fileref,
20                   t1.xpath,
21                   t1.xengine,
22                   t1.modate
23               FROM SASHELP.VEXTFL t1;
                                          The SAS System       14:45 Monday, November 13, 2017   2

                                                                        Engine
Fileref   Pathname                                                      Name         Date Modified
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
#LN00003  J:\Files\New Text Document.log                                DISK      13NOV17:14:45:21
#LN00004  J:\Files\New Text Document.lst                                DISK      13NOV17:14:27:32
#LN00005  J:\Files\New Text Document.sas                                DISK      13NOV17:14:45:10
SASAUTO1  \\XXXXXXXXXXXX\admin\SASAUTO1                                 DISK      12OCT16:09:19:00
RLINK     C:\Program                                                    DISK      09OCT17:09:29:22
          Files\SASHome\x86\SASFoundation\9.4\CONNECT\SASLINK\TCPWiN.                            
          SCR                                                                                    
#LN00001  C:\Program Files\SASHome\x86\SASFoundation\9.4\core\sasmsg    DISK      05JUN17:14:39:57
#LN00001  C:\Program                                                    DISK      05JUN17:14:39:57
          Files\SASHome\x86\SASFoundation\9.4\accelmva\sasmsg                                    
#LN00001  C:\Program Files\SASHome\x86\SASFoundation\9.4\access\sasmsg  DISK      05JUN17:14:39:57
#LN00001  C:\Program Files\SASHome\x86\SASFoundation\9.4\cmp\sasmsg     DISK      05JUN17:14:39:57
#LN00001  C:\Program Files\SASHome\x86\SASFoundation\9.4\graph\sasmsg   DISK      05JUN17:14:39:57
#LN00001  C:\Program                                                    DISK      05JUN17:14:39:57
          Files\SASHome\x86\SASFoundation\9.4\spdsclient\sasmsg                                  
#LN00002  C:\Users\xxxxxxxx\SAS\connect-saslink                         DISK      13OCT17:15:24:22
 
 [...spaces...] 
 
 4         QUIT;
NOTE: The PROCEDURE SQL printed page 2.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.06 seconds
      cpu time            0.00 seconds
     

25        
26        

NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
      real time           1.52 seconds
      cpu time            0.37 seconds
     

View solution in original post

8 REPLIES 8
JohnHoughton
Quartz | Level 8

 

 

From the PROC PRINTTO documentation

 http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000146809.htm

 

Tip:To route the SAS log and procedure output to the same file, specify the same file with both the LOG= and PRINT= options.
PhilC
Rhodochrosite | Level 12
proc printto print=log; run;

doesn't work.  (thanks)

 

Reeza
Super User

If you route it to a file it does?

 

filename output 'c:\_localdata\temp\test.txt';
proc printto print=output log=output; run;

proc means data=sashelp.class;
run;
PhilC
Rhodochrosite | Level 12

True, but .... yuck.  adding to the question:  "Using batch mode, without passing arguments to SAS regarding current directory or command line arguments."

Reeza
Super User

Naive question...doesn't batch generate a separate log file by default? Wouldn't set PROC PRINTTO within the batch process direct it to a separate file anyways?

PhilC
Rhodochrosite | Level 12

Ok Reeza, yes.  Because you asked that question like that, made me think outside the box, so then I just went and solved my own problem.  Thanks for the inspiration.

 

SAS Code:

PROC SQL outobs=1 noprint;
   SELECT t1.fileref
     INTO :LOG_FILEREF
     FROM SASHELP.VEXTFL t1
       where t1.xpath like '%.log%';
QUIT;

%put NOTE: LOG_FILEREF=&LOG_FILEREF;

proc printto print=&LOG_FILEREF; run;

proc print data=SASHELP.cars (obs=3);
  var _ALL_;
run;

PROC SQL;
   SELECT t1.fileref, 
          t1.xpath, 
          t1.xengine, 
          t1.modate
      FROM SASHELP.VEXTFL t1;
QUIT;

Producing output log:

 

NOTE: AUTOEXEC processing completed.

 

1          PROC SQL outobs=1 noprint;
2             SELECT t1.fileref
3               INTO :LOG_FILEREF
4               FROM SASHELP.VEXTFL t1
5                 where t1.xpath like '%.log%';
6          QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds
     

SYMBOLGEN:  Macro variable LOG_FILEREF resolves to #LN00003
7         
8          %put NOTE: LOG_FILEREF=&LOG_FILEREF;
3                                         The SAS System           14:45 Monday, November 13, 2017

NOTE: LOG_FILEREF=#LN00003
9         
10         proc printto print=&LOG_FILEREF; run;
SYMBOLGEN:  Macro variable LOG_FILEREF resolves to #LN00003

NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
     

11        
12         proc print data=SASHELP.cars (obs=3);
13           var _ALL_;
14         run;

                                          The SAS System       14:45 Monday, November 13, 2017   1

                                                                               M
                                           D                      E     H      P
                                           r                      n  C  o      G       W
                                           i                      g  y  r   M  _       h
                                           v                I     i  l  s   P  H       e
                                     O     e                n     n  i  e   G  i   W   e   L
                     M               r     T                v     e  n  p   _  g   e   l   e
           M         o          T    i     r       M        o     S  d  o   C  h   i   b   n
      O    a         d          y    g     a       S        i     i  e  w   i  w   g   a   g
      b    k         e          p    i     i       R        c     z  r  e   t  a   h   s   t
      s    e         l          e    n     n       P        e     e  s  r   y  y   t   e   h

       1 Acura MDX            SUV   Asia All    $36,945  $33,337 3.5 6 265 17 23 4451 106 189
       2 Acura RSX Type S 2dr Sedan Asia Front  $23,820  $21,761 2.0 4 200 24 31 2778 101 172
       3 Acura TSX 4dr        Sedan Asia Front  $26,990  $24,647 2.4 4 200 22 29 3230 105 183
 
 [...spaces...] 

NOTE: There were 3 observations read from the data set SASHELP.CARS.
NOTE: The PROCEDURE PRINT printed page 1.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
     

15        
16         *proc printto log=&LOG_FILEREF; run;
17        
18         PROC SQL;
19            SELECT t1.fileref,
20                   t1.xpath,
21                   t1.xengine,
22                   t1.modate
23               FROM SASHELP.VEXTFL t1;
                                          The SAS System       14:45 Monday, November 13, 2017   2

                                                                        Engine
Fileref   Pathname                                                      Name         Date Modified
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
#LN00003  J:\Files\New Text Document.log                                DISK      13NOV17:14:45:21
#LN00004  J:\Files\New Text Document.lst                                DISK      13NOV17:14:27:32
#LN00005  J:\Files\New Text Document.sas                                DISK      13NOV17:14:45:10
SASAUTO1  \\XXXXXXXXXXXX\admin\SASAUTO1                                 DISK      12OCT16:09:19:00
RLINK     C:\Program                                                    DISK      09OCT17:09:29:22
          Files\SASHome\x86\SASFoundation\9.4\CONNECT\SASLINK\TCPWiN.                            
          SCR                                                                                    
#LN00001  C:\Program Files\SASHome\x86\SASFoundation\9.4\core\sasmsg    DISK      05JUN17:14:39:57
#LN00001  C:\Program                                                    DISK      05JUN17:14:39:57
          Files\SASHome\x86\SASFoundation\9.4\accelmva\sasmsg                                    
#LN00001  C:\Program Files\SASHome\x86\SASFoundation\9.4\access\sasmsg  DISK      05JUN17:14:39:57
#LN00001  C:\Program Files\SASHome\x86\SASFoundation\9.4\cmp\sasmsg     DISK      05JUN17:14:39:57
#LN00001  C:\Program Files\SASHome\x86\SASFoundation\9.4\graph\sasmsg   DISK      05JUN17:14:39:57
#LN00001  C:\Program                                                    DISK      05JUN17:14:39:57
          Files\SASHome\x86\SASFoundation\9.4\spdsclient\sasmsg                                  
#LN00002  C:\Users\xxxxxxxx\SAS\connect-saslink                         DISK      13OCT17:15:24:22
 
 [...spaces...] 
 
 4         QUIT;
NOTE: The PROCEDURE SQL printed page 2.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.06 seconds
      cpu time            0.00 seconds
     

25        
26        

NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
      real time           1.52 seconds
      cpu time            0.37 seconds
     
Reeza
Super User

Jupyter notebooks puts everything in one place if that's what you're trying to accomplish.

PhilC
Rhodochrosite | Level 12

No, but... I forgot about Jupyter..  and OOHH... it is now supported on Windows!  I didn't know this! 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 3287 views
  • 9 likes
  • 3 in conversation