sas中的sql(5) 縱向操作資料集 Except、Intersect、Union、OuterJoin

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   使用   sp   strong   資料   

SQL進行縱向操作的基本文法

proc sql;select *from table1set-operator <all> <corr>select *from table2set-operator <all> <corr>select *from table3;

1:幾種set操作符 Except、Intersect、Union、OuterJoin 

Except、Intersect、Union三種set符號是預設進行unique處理,當進行unique處理時會進行如下兩步操作

1. PROC SQL eliminates duplicate (nonunique) rows in the tables.
2. PROC SQL selects the rows that meet the criteria and, where requested, overlays columns.

當進行的操作同時需要展現unique和duplicate行時則只會進行第二步,忽略第一步。

 

Except、Intersect、Union三種set符號對於列的處理時按位置操作,不管對應列的名稱(有別名的根據別名來)是否相同。當重疊時,按第一張表的名稱命名當前列,如果無名稱則以第二張表對應列的名稱來命名。

第一張表和第二張表對應列的資料類型必須相同,否則無法進行操作

OuterJoin不會覆蓋列

 

Corr和All關鍵字

2.1:Except(預設列對應位置操作)

預設情況下此過程分兩步進行

1:進行unique,將one中重複的行刪除。

2:對照one two,將one在two中的行刪除。

 

單獨加上all關鍵字

不進行unique步,保持原樣直接篩選。(省略第一步可以提高效率)

單獨加上corr關鍵字

按列名進行合并,不同列名全部刪除。

進行unique步驟,再將two在one中的相同行進行刪除

同時加上all和corr

1:先按列名刪減列

2:不進行unique,保留重複行,然後再在one中刪除two中有的行。

 

 

2.2:intersect 文法一樣,具體不懂再翻閱資料

2.3:union 文法一樣,具體不懂再翻閱資料 union對非all的資料集會進行排序

2.4:outer Union(本來就有all的性質,所以無法和all一起使用)

1:selecting all rows (both unique and nonunique) from both tables

2:not overlaying columns.

 

無關鍵詞情況下的文法

使用corr關鍵字

 

sas中的sql(5) 縱向操作資料集 Except、Intersect、Union、OuterJoin

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.