Re: [程式] sas資料處理問題

看板Statistics作者 (咖啡王子)時間9年前 (2016/04/13 23:18), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
: 目前手上的資料如下: : 公司 員工 年度 薪酬 排名(依公司當年度薪酬) : 甲 A 2000 400 1 : 甲 B 2000 300 2 : 甲 C 2000 200 3 : 乙 D 2002 600 1 : 乙 E 2002 500 2 : 丙 F 2005 750 1 : 丙 G 2005 650 2 : 丙 H 2005 550 3 : 丙 I 2005 450 4 proc sort data=salary;by cusip year descending salary; run; proc means data=salary noprint; var salary; output out=min(drop=_type_ _freq_) min=salary n=n; run; /*先處理n<5的*/ data min(drop=n i); set min(where=(n<5)); do i=1 to 5-n; output; end; run; /*要求輸出前五大*/ data salary(keep=cusip year salary); set salary; by cusip year; retain n 0; n=n+1; if first.cusip then n=1; if first.year then n=1; if n<=5 then output; run; data salary; set salary min; run; proc sort data=salary;by cusip year; run; /* 以上完成 我是直接在bbs上打 所以也不確定能不能work 但是邏輯上應該不會有問題 你自己試試看吧 有問題歡迎來信 sas@jlu.edu.cn 現在要上ptt得翻牆*/ -- -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.76.254.33 ※ 文章網址: https://www.ptt.cc/bbs/Statistics/M.1460560694.A.333.html
文章代碼(AID): #1N3cCsCp (Statistics)
討論串 (同標題文章)
文章代碼(AID): #1N3cCsCp (Statistics)