首先给点击进来的各位大神拜个晚年! 正在读SAS ADVANCED prep guide,其中第七章 “Creating andManaging Views Using PROC SQL”中提到,对于类似proc sql; create view sasuser.a as select * from sasuser.b; 这样的程序,最好将from语句中sasuser.b用一级名称书写,也就是省略sasuser.,直接写b的方式,这样会默认b也在a所在library sasuser之下。这样简写的好处是可以“prevents you from having to change the view if you assign a different libref to the SAS data library that contains the view and its contributing table or tables.”(没太看懂在说啥。。。)
然后因为直接在from语句中写b的话,很容易混淆成work.b;而且有时会需要作为view的a和作为数据来源表格的b不在同一文件夹下,所以书中又介绍了使用Embedded LIBNAME Statement的方法:
libname m "E:\aa";
proc sql;
create view sasuser.a as
select* from m.b
using libname m "E:\bb";
quit;
书中还说明了外部libname和embedded libname互不冲突,embedded libname只对sql有效,所以用同一libref m没有问题。如上面程序中m.b就是存在于"E:\bb"之中。