[程式] sas資料處理(balanced panel data)

看板Statistics作者 (嘆這世間無奈好多)時間14年前 (2012/01/13 19:51), 編輯推噓1(104)
留言5則, 2人參與, 最新討論串1/2 (看更多)
------------------------------------------------------------------------[軟體程式類別]: [程式問題]: SAS處理panel data [軟體熟悉度]: 中(3個月到1年) [問題敘述]: 各位前輩好 我有一份panel data的資料要處理成balanced panel 把unbalanced的部份拿掉 例如 company year A 1 A 2 A 3 A 4 A 5 B 1 B 2 B 4 B 5 C 1 C 2 C 3 C 4 像B跟C要拿掉 我的問題應該蠻容易的 只是不太知道有哪些指令可以運用 [程式範例]: 我原本的想法是這樣寫 proc sort data=xxx; by company year; run; if company^= lag(company) and year=1; then do; new_variable=1; end; else if company ^= lag(company) and year ^= 1 then delete; else if company = lag(company) and year ^= lag(year)+1 then delete; else if company = lag(company) and year = lag(year)+1 ;then do; new_variable = lag(new_variable)+1; end; 把unbalanced的部份拿掉 結果跟想像的完全不一樣@@ 懇請各位前輩們指點 m(_ _)m ----------------------------------------------------------------------------- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.4.181

01/13 19:56, , 1F
另外請教一下想知道資料中每個company有幾筆資料
01/13 19:56, 1F

01/13 19:56, , 2F
該用什麼指令?(這個應該就解決我的問題了@@)
01/13 19:56, 2F

01/13 20:06, , 3F
你說的balanced是指year一定要1~5年嗎
01/13 20:06, 3F

01/13 20:30, , 4F
是的是的 只要缺其中一年就整個company拿掉 我是9.1版
01/13 20:30, 4F

01/13 20:31, , 5F
剛剛估狗到9.2有PROC PANEL這個指令可惜9.1沒有@ @
01/13 20:31, 5F
文章代碼(AID): #1F41hHN3 (Statistics)
文章代碼(AID): #1F41hHN3 (Statistics)