1 / 17

STATA 基礎教學

STATA 基礎教學. 洪仲林 hung0509@gmail.com. 使用 Stata 的時機. 需要處理 大量 資料 需要處理重複工作 需要較新的統計或計量方法 投稿專業期刊. Stata 版本. Small 、 IC 、 SE 、 MP 、 LAB Small 為教學用 IC 以上為研究用 MP 為多核心電腦用 LAB 多人使用. Stata 11 視窗. 工具列. 快捷列. 歷史指令視窗. 變數視窗. 執行結果視窗. 指令輸入視窗. 快捷列. 變數管理視窗. 執行結果記錄. 搜尋. 程式撰寫視窗. 資料編輯視窗.

sabina
Download Presentation

STATA 基礎教學

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. STATA 基礎教學 洪仲林 hung0509@gmail.com

  2. 使用Stata的時機 • 需要處理大量資料 • 需要處理重複工作 • 需要較新的統計或計量方法 • 投稿專業期刊

  3. Stata版本 • Small、IC、SE、MP、LAB • Small為教學用 • IC以上為研究用 • MP為多核心電腦用 • LAB 多人使用

  4. Stata 11 視窗 工具列 快捷列 歷史指令視窗 變數視窗 執行結果視窗 指令輸入視窗

  5. 快捷列 變數管理視窗 執行結果記錄 搜尋 程式撰寫視窗 資料編輯視窗

  6. 如何輸入資料一 • 按快捷列資料編輯視窗,開啟工作表,直接複製貼上 • 直接輸入資料

  7. 如何輸入資料二 • 使用點選輸入 • 工具列---File---Import • 使用指令輸入 • 在指令輸入視窗鍵入 • Insheet using 檔名

  8. 變數名稱與標籤處理 • rename 舊變數名稱 新變數名稱 • 例:rename o gender • 新增變數標籤 • 例: label variable gender “性別” • 新增樣本標籤 • 例: label define genderlb 1 “男”2 “女” • 顯示樣本標籤 • 例:label values gender genderlb

  9. 刪除或保留資料 • drop 刪除變數 • 例:drop gender • keep 保留變數 • 例:keep smoke drink • 刪除或保留變數加上條件 • 例:drop if numofprivate<1 (沒給錢的小孩刪除) • 例:keep if smoke==0 & drink==0 & gender==1 (挑丈夫)

  10. 資料描述一 • list 變數名稱 in if (顯示資料) • 例:list age-marr in 1/100 • summarize 變數名稱 (樣本數、平均數、標準差、最大最小值) • 例:summarize education- exercise

  11. 資料描述二 • tab 某一個變數 • 例:tab gender • tab 某兩個變數 • 例: tab gendereducation, column or row • tab 某兩個變數, summarize(某一個變數) • 例:tab gender education, summarize( marr) • table某三個變數(類似樞紐分析) • 例: table gender educationmarr

  12. 資料處理一 • gen 變數名稱=條件 • 例:gen biryear=2010-age (計算出生年) • gen 變數名稱=條件 if 條件 • 例:gen income=1 if wageincome==1 | retireincome==1 | rentincome==1 (歸類有收入) • replace income=0 if income=.(歸類無收入) • gen age5 = autocode(age, 5, 67, 87) • 例:generate age5 = autocode(age, 5, 67, 87)(五歲分成一群)

  13. 資料處理二 • destring文字改數字 • destring , gen(變數名稱)or replace • tostring數字改文字 • tostring , gen(變數名稱)or replace

  14. 資料處理三 • sort 排序 • sortgender education • gsort降幕或升幕 • gsort gender –education • 儲存檔案 • save female,replace • 開啟檔案 • use female, clear

  15. 資料處理四 • merge • sortgender education • append

  16. 資料分析 • 線性迴歸 • regress 獨立變數 相依變數 • 單因子變異數分析 • oneway age marr

  17. Do-File • 將重複性的程式儲存於檔案中,類似批次檔功能 • 可點選快捷列中的程式撰寫視窗後進行撰寫 • 也可於記事本中撰寫好之後,再貼到Stata中

More Related