sas中的sql(8)sql选项解析,数据字典

 1:Proc sql中的选项

 1.1:INOBS/OUTOBS=

这个选项意思在前面的随笔中已说过,就INOBS这里有个例子

这里的INOBS=5是针对于两张表分别读入5个,而不是一共读入五个

1.2:NUMBER/NONUMBER

效果如下

1.3:Double/NoDouble

Double Spacing your output to make it easier to read.

 1.4:FLOW | NOFLOW | FLOW=n | FLOW=n m

The FLOW option causes text to be flowed in its column instead of wrapping the entire row

n sets the width of the flowed column

n m使得列的宽度在n - m之间

1.5:STIMER | NOSTIMER

NOSTIMER为默认,当为默认时效果如下

两个select语句的运行时间被一起计算,没有起到比较的效果

使用STIMER后,起到了比较的效果

 1.6:Resetting Options

You can use the RESET statement to add, drop, or change PROC SQL options without reinvoking the SQL procedure.

添加

proc sql outobs=5;
select flightnumber, destination
from sasuser.internationalflights;
reset number;
select flightnumber, destination
from sasuser.internationalflights
where boarded gt 200;
quit;

删除

proc sql number;
select name, address, city, state, zipcode
from sasuser.frequentflyers;
reset nonumber;
select name, address, city, state, zipcode
from sasuser.frequentflyers
where pointsearned gt 7000
and pointsused lt 3000;
quit;

2:数据字典

Dictionary tables are special, read-only SAS tables that contain information about SAS data libraries, SAS macros, and external files that are in use or available in the current SAS session.(除了不能改变表,其他的一切对已表的基本操作都可以做)
Dictionary tables also contain the settings for SAS system options and SAS titles and footnotes that are currently in effect,Dictionary.Columns table contains information (such as name, type, length, and format) about all columns

Dictionary table by referring to the PROC SQL view of the table that is stored in the Sashelp library.

dictionary tables只能通过sql访问,表或视图都行

使用数据字典

proc sql;
    describe table dictionary.tables;
quit;
/*这里是一部分关于表的描述信息*/
create
table DICTIONARY.TABLES ( libname char(8) label='Library Name', memname char(32) label='Member Name', memtype char(8) label='Member Type', dbms_memtype char(32) label='DBMS Member Type', memlabel char(256) label='Data Set Label', typemem char(8) label='Data Set Type', crdate num format=DATETIME informat=DATETIME label='Date Created', modate num format=DATETIME informat=DATETIME label='Date Modified', nobs num label='Number of Physical Observations', obslen num label='Observation Length', nvar num label='Number of Variables', protect char(3) label='Type of Password Protection', compress char(8) label='Compression Routine', encrypt char(8) label='Encryption',
.......
);
/*我们选择库SASUSER中的所有表,以及他们的观测值数量,变量数,和建表日期等变量*/
proc
sql; select memname format=$20., nobs, nvar, crdate from dictionary.tables where libname='SASUSER';
/*查询SASUSER库中含有列EmpID的所有表名*/
proc
sql; select memname from dictionary.columns where libname='SASUSER' and name='EmpID';
原文地址:https://www.cnblogs.com/yican/p/4105807.html