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';

 


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com