Is it possible to (simply) write lst output to the SAS log? In my case I want to see a very short Proc Print in the log itself. Seems to me there should be a
proc printto print=log;
kind of option... not?
I'm on Linux Base SAS 9.4M6.
Are you running interactively or not? It not you might be able to do something using Unix redirection and the -stdio command line option.
Otherwise you will need a lot more code to first point PRINT to a file, using PROC PRINTTO or ODS LISTING, close it, read it in and dump it to the log.
Example:
1167 filename print2 temp; 1168 proc printto print=print2; run; NOTE: PROCEDURE PRINTTO used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 1169 proc print data=sashelp.class (obs=3); run; NOTE: There were 3 observations read from the data set SASHELP.CLASS. NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 1170 proc printto print=print; run; NOTE: PROCEDURE PRINTTO used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 1171 data _null_; 1172 infile print2; 1173 input; 1174 put _infile_; 1175 run; NOTE: The infile PRINT2 is: Filename=...#LN00070, RECFM=V,LRECL=32767,File Size (bytes)=313, Last Modified=10Jan2020:09:23:52, Create Time=10Jan2020:09:23:52 SAS 9.4 on WINDOWS 19:09 Monday, January 6, 2020 1753 Obs Name Sex Age Height Weight 1 Alfred M 14 69.0 112.5 2 Alice F 13 56.5 84.0 3 Barbara F 13 65.3 98.0 NOTE: 7 records were read from the infile PRINT2. The minimum record length was 0. The maximum record length was 107. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
Are you running interactively or not? It not you might be able to do something using Unix redirection and the -stdio command line option.
Otherwise you will need a lot more code to first point PRINT to a file, using PROC PRINTTO or ODS LISTING, close it, read it in and dump it to the log.
Example:
1167 filename print2 temp; 1168 proc printto print=print2; run; NOTE: PROCEDURE PRINTTO used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 1169 proc print data=sashelp.class (obs=3); run; NOTE: There were 3 observations read from the data set SASHELP.CLASS. NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 1170 proc printto print=print; run; NOTE: PROCEDURE PRINTTO used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 1171 data _null_; 1172 infile print2; 1173 input; 1174 put _infile_; 1175 run; NOTE: The infile PRINT2 is: Filename=...#LN00070, RECFM=V,LRECL=32767,File Size (bytes)=313, Last Modified=10Jan2020:09:23:52, Create Time=10Jan2020:09:23:52 SAS 9.4 on WINDOWS 19:09 Monday, January 6, 2020 1753 Obs Name Sex Age Height Weight 1 Alfred M 14 69.0 112.5 2 Alice F 13 56.5 84.0 3 Barbara F 13 65.3 98.0 NOTE: 7 records were read from the infile PRINT2. The minimum record length was 0. The maximum record length was 107. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
Tom,
I'm running in batch mode, Linux SAS. Thanks - that's a good solution - that would work and I may use it later. And thanks for your quick reply! In the meantime I employed the lost art of the data _null_ report...
data _null_;
if _n_ = 1 then do;
put @01/ 132*"=";
put @01 Count of Oracle table rows and available SAS BRI input load file rows, %sysfunc(datetime(),datetime19.)";
put @01 " Dataset printed: &out, Program: %sysfunc(getoption(sysin))" /;
put / @01 "db schema table ora_ct sas_ct diff sas_file" /;
end;
set &out END=lastrec;
put @01 db
@09 schema
@20 table
@30 ora_ct
@40 sas_ct
@50 diff
@65 sas_file
;
if lastrec then put / 132*"=" /;
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.