1.資料的基本信息
①summarize
summarize:匯總所有變量的名稱,個案數目,均值,標准差等,縮寫為sum
format age %6.2f:指定age變量的統計量輸出時的保留2位小數
sum age, format:結合上個命令,對年齡變量進行描述的匯總保留2位小數
sum age,detail:匯總更加詳細的信息
②codebook
codebook沒有sum詳細
codebook:匯總所有變量
codebook var:匯總var變量
③inspect
inspect age:可以畫出簡單的直方圖
2.基本信息的統計
①tabulate和table命令
tabulate places:對places變量進行列表統計,此命令可縮寫為tab
table places:只有頻數統計,不可縮寫為tab
tab places price:統計不同地方的價格的列表
tab places price:統計不同places的price的列表
②tabstat命令
tabstat price places:顯示2個變量的平均值
tabstat price places, stats(mean med min max):顯示2個變量的平均值,中位數等統計量
tabstat price places, stat(mean med min max p25) col(s) format(%6.2f):均值等統計量在表格的行中,並且將結果小數點保持在2位。此命令也可以寫為tabstat price places, s(mean med min max) c(s) f(%6.2f)。
tabstat price places, s(mean med min max) c(s) f(%6.2f) by (gender):根據性別分類來陳述上述的統計量。
③結果呈現
(1)將Stata中的結果選中,右擊鼠標選擇Copy table,直接貼入Excel或者Word。
(2)通過命令將其直接保存在txt文件
tabexport var using results.txt, s(mean sd) replace //此處的tabexport命令第一次使用時應當進行安裝,安裝命令為ssc install tabexport
shellout results.txt //打開txt文件以便查看結果,此結果可直接復制到Excel中
tabexport var using results.txt, s(mean sd) by(gender) noreshape replace format(%6.2f) //此處根據性別輸出var的統計量,並定義均數和標准差的輸出顯示格式為保留2位小數
tabexport ba004 using results.txt, s(count mean sd) by(rgender) noreshape replace format(%6.0f %6.2f %6.3f) //根據呈現的需求,format命令可以依次定義各個變量
shellout results.txt