看板 Statistics 關於我們 聯絡資訊
proc means noprint data=a; var 任意變項; BY YEAR FIRM ANALYST; output out=b n=n; run; proc sort data=b;by year firm; run; proc means noprint data=b; var n; BY YEAR FIRM ; output out=c n=n; run; proc sort data=b;by year analyst; proc means noprint data=b; var 任意變項; BY YEAR ANALYST; output out=d n=n; run; ※ 引述《duckduck2 (只來看文章的ptt)》之銘言: : tew:proc means ;by year 公司 分析師 : tew:再把上述結果 依照by year 公司;其有效觀察值 就是1個? : tew:然第一個結果的 依 by year 分析師; 其有效觀察值 : tew:以上方法 都是用proc means;就OK了 : tew:不知道前面我有沒有回答過 一家基金每個月持有幾家公司 : tew:跟一家公司 每個月被幾家基金公司持有 其實是一樣的 : 想請問一下~我試了你第一個步驟,且跑出一張表了 : 表格是在output裡 : 可是我要怎麼"把上述結果依照by year 公司;其有效觀察值" : 那個"其有效觀察值"我不太懂@@ : 而且我看LOG檔有發現執行錯誤 : ERROR: Expecting page 3, got page -1 instead. : ERROR: Page validation error while writing WORK._tf0002.ITEMSTOR. : ERROR: File WORK._tf0002.ITEMSTOR is damaged. I/O processing : did not complete. : NOTE: The above message was for the following by-group: : ey=1982 CUSIP/SEDOL= Analyst Code=030130 : ERROR: Data set WORK.A is not sorted in ascending sequence. The current : by-group has Analyst Code = 031231 : and the next by-group has Analyst Code = 001652. : 其中ey是我截取end date出來的年度 : ey=year(enddate); : 不好意思~我真的不太懂>< : ※ 引述《duckduck2 (只來看文章的ptt)》之銘言: : 假設有四個變數分別為end date,forecast date,firm code,analyst code : 日期為yymmdd格式,資料舉例如下: : end date forecast date firm code analyst code : 19820430 19820213 01387110 000015 : 19820430 19810824 01387110 000226 : 19830831 19830511 25917GA0 000015 : 19830831 19821216 25917GA0 000461 : 19830831 19830111 25917GA0 000015 : 19851231 19850616 36710256 000226 : 19861231 19860828 48536121 000864 : 依此類推 依此類推 依此類推 依此類推 : 資料有非常多筆 : 而每間公司的end date都不一樣 : forecast date是analyst 對這家公司發出預測的日子 : 我想求的是 : 每一年,一間公司(firm)有多少分析師(analyst)在追蹤? : 舉end date為1983年來說,雖然有三筆資料,但其實只有兩個分析師在追蹤 : 也就是在同一年裡,分析師重覆發的預測,總共只能算他是一個人 : 因為他雖然發很多筆,但都是同一個人發的,所以人數只要算1 : 之前從板上知道,"table var1 var2"可以算出數量 : 但是我後來了解這是適合code不重覆的情況 : 我曾經試過nodup,但發現不可行 : 而且還會把其他我需要的data刪掉 : 所以我想知道 : 每一年,一間公司(firm)有多少分析師(analyst)在追蹤? : 即使他在那年對同一間公司發了十筆,一樣只算一個人 : 另外,如果我想求 : 每一年,一個分析師追蹤多少間公司 : 方法是否也跟上面的差不多呢? : 謝謝大大們~! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 134.208.29.118
duckduck2:謝謝^^!~我會試弄看看~! 04/11 22:43