我们知道,如果在SAS里定义一个视图,而视图的源代码太多时,你通过describe语句把源代码输出到日志的时候
会发现输出信息会自动给你换行,这样导致你从日志里复制出来的源代码必须经过修改才能用
而下面这个代码就是解决这个问题,可以直接把SAS SQL视图的源代码直接输出到文件,输出的SQL语句可以直接复制出运行而不会给你乱换行
%let viewname=你的视图名字;
%let outfile=d:/1.sas;
options linesize=80;
filename out temp;
proc printto log=out new;
proc sql;
describe view &viewname;
quit;
proc printto;
run;
options linesize=max;
data _null_;
infile out truncover;
file "&outfile" lrecl=20000;
input line $char80.;
if index(line, 'NOTE:') then do;
input;
do until (line = ' ');
input line $80.;
if line ne ' ' then do;
put line @@;
/*如果读取的字节数没有超过80,说明其是一个独立的行,则直接换行输出,否则不换行输出*/
if length(line)^=80 then put ;
end;
end;
end;
put ;
run;