以下内容:
proc sql; describe table sashelp.class;生成(在日志中):
create table SASHELP.CLASS( label='Student Data' bufsize=4096 )
(
Name char(8),
Sex char(1),
Age num,
Height num,
Weight num
);任何完整性约束都会发送到输出窗口-可通过以下方式在SAS中访问:
ods output IntegrityConstraints=MyDataset;除了重定向日志(proc printto)或构建生成器(通过proc contents或字典/ sashelp视图)之外,还有其他方法可以提取上述DDL吗?
我尝试了ODS跟踪,但看不到任何其他正在创建的输出。
发布于 2015-02-28 00:04:29
如果你乐于重定向你的日志(尽管是暂时的),以下可能是有用的:
/* macro */
%macro get_ddl(ds=,outfile=);
filename tmp temp;
proc printto log=tmp;quit;
proc sql; describe table &ds;
proc printto log=log;quit;
data _null_;
infile tmp;
file &outfile;
input;
if _infile_=:'NOTE: SQL table ' then start+1;
else if _infile_=:'NOTE: PROCEDURE SQL used' then stop;
else if index(_infile_,' The SAS System ') then delete;
else if start=1 then put _infile_;
putlog _infile_;
run;
filename tmp;
%mend;
/* test */
proc sql;
create table people
(
name char(14),
gender char(6),
hired num,
jobtype char(1) not null,
status char(10),
constraint prim_key primary key(name),
constraint gender check(gender in ('male' 'female')),
constraint status check(status in ('permanent'
'temporary' 'terminated'))
);
%get_ddl(ds=people,outfile="C:\temp\test.ddl");请注意,列约束不在上面的输出上(它们需要从IntegrityConstraints输出派生)。
不过,这个信息不能“重定向”确实让人觉得有点奇怪。
https://stackoverflow.com/questions/28768792
复制相似问题