我想出了一个办法:
-
使用
PROC PRINTTO
将我的项目日志重定向到服务器上的一个文件,在该文件中我可以从SAS(而不是R)写入。
-
将此文件作为带分隔符的文件读取到表中,使用一个外来的分隔符,我只需尝试在代码中不使用它(不幸的是,没有分隔符似乎不是一个选项)。
-
从r导入此表并修剪不相关的第一行
我的SAS代码:
%let writeable_folder_on_server = /some_path/;
%let temp_log_for_R = &writeable_folder_on_server/temp_log_for_R.txt;
%let log_as_tbl = mylib.mytbl;
proc printto log="&temp_log_for_R" print="&temp_log_for_R" new;
run;
proc datasets library= mylib nolist;
delete mytbl;
run;
/* code producing log */
%put foo;
%put bar;
proc import datafile="&temp_log_for_R" out=&log_as_tbl dbms=dlm replace;
delimiter='§';
getnames=no;
GUESSINGROWS=MAX;
run;
的替换参数
IMPORT
过程“应该”使表删除成为多余的,但出于某种原因(可能是因为我使用了Oracle库),它没有。
它生成以下输出,存储在表中:
NOTE: PROCEDURE PRINTTO used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.01 seconds
memory 904.75k
OS Memory 15140.00k
Timestamp 01/30/2019 01:29:21 PM
Page Faults 2
Page Reclaims 251
Page Swaps 0
Voluntary Context Switches 1
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
28
29 proc datasets library= mylib nolist;
30 delete mytbl;
31 run;
NOTE: Deleting mylib.mytbl (memtype=DATA)
32
33 /* code producing log */
34 %put foo;
foo
35 %put bar;
bar
36
NOTE: PROCEDURE DATASETS used (Total process time)
real time 0.17 seconds
user cpu time 0.02 seconds
system cpu time 0.00 seconds
memory 2425.56k
OS Memory 17956.00k
Timestamp 01/30/2019 01:29:21 PM
2
Page Faults 5
Page Reclaims 858
Page Swaps 0
Voluntary Context Switches 57
Involuntary Context Switches 4
Block Input Operations 0
Block Output Operations 0