版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://logistic.blogbus.com/logs/73399856.html
1.直接用SQL语句访问Dictionary table
2.访问SAShelp View
打开explorer window,在SASHELP这个library下,以V开头的视图实际上是Dictionary table内容的复制。如
proc sql;describe view sashelp.voption;quit;
可以看到voption这个视图的内容来自dictionary.options。
而对于View,除了SQL,直接用data步或proc步都可以访问。如
data test2;
set sashelp.vcolumn;
where libname="WORK" and memname="TEST";
run;
或者
proc contents data=sashelp.voption;
run;
或者在command栏输入viewtable sashelp.voption。
Dictionary table的最常见的几个应用:
一、取出数据集的变量数和观测数
proc sql;
select nobs,nvar
into:nobs,:nvar
from dictionary.tables
where libname="WORK" and memname="TEST";
quit;
二、取出某一数据集的所有变量名
proc sql;
select name into :varlist
separated by " "
from dictionary.columns
where libname="WORK" and memname="TEST";
quit;
%put &varlist.;
三、取出某个library下所有数据集名
proc sql;
select memname into :dsname
separated by " "
from dictionary.tables
where libname="WORK";
quit;
四、取出所有的宏变量名
proc sql noprint;
create table macv as
select name
from dictionary.macros
where offset=0 and scope="GLOBAL";
quit;
效果同 %put _global_;