SAS:(7)變數的次數分配表與列聯表:PROC FREQ敘述句的介紹

簡介

PROC FREQ 有兩種主要功能:

  1. 次數分配表
  2. 多個分類變數的交叉列聯表,並可計算其卡方檢定量

syntax

1.基本語法

1.1 產生單變數(VarA)之次數分配表

Proc freq (data=資料集名);
Table VarA;

1.2 個別產生變數A1,變數A2,……,變數An之次數分配表

Proc freq (data=資料集名);
table VarA1 VarA2 VarA3….Varn;

1.3 產生變數A與變數B的交叉列聯表

proc freq (data=資料集名);
Table VarA*VarB;

1.4 個別產生變數A與B的交叉列聯表,以及變數A與C的交叉列聯表

Proc freq (data=資料集名);
table varA*(varB varC);

1.5 產生在變數A的不同值中,變數B與變數C的交叉列聯表

proc freq (data=資料集名);
table varA*varB*varC;

1.6 對變數A與變數B做獨立性卡方檢定

2.選擇功能

2.1搭配分群變數使用

Proc freq;
table ….;
by 分群變數;

2.2搭配加權變數使用

proc freq
table …;
weight 加權變數;

注意:加權變數通常為觀察值

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License