看板 Statistics 關於我們 聯絡資訊
[軟體程式類別]: SAS [程式問題]: 資料處理 [軟體熟悉度]: 低(1~3個月) [問題敘述]: 抓取每月最後一天的資料 symbol name date prc vol ind ret 1. 1111 aaa 2010-01-01 b1 c1 d1 0.ab1 2. 1111 aaa 2010-01-02 b2 c2 d2 0.ab2 ... 31. 1111 aaa 2010-01-31 b31 c31 d31 0.ab31 32. 1111 aaa 2010-02-01 b32 c32 d32 0.ab32 59. 1111 aaa 2010-02-28 b59 c59 d59 0.ab59 60. 1111 aaa 2010-03-01 b60 c60 d60 0.ab60 ... 90. 1111 eee 2010-03-31 b90 c90 d90 0.ef90 91. 1111 eee 2010-01-01 f1 g1 h1 0.ef1 121. 1111 eee 2010-01-31 f31 g31 h31 0.ef31 122. 1111 eee 2010-02-01 f32 g32 h32 0.ef32 ... 149. 1111 eee 2010-02-28 f59 g59 h59 0.ef59 150. 1111 eee 2010-03-01 f60 g60 h60 0.ef60 ... 180. 1111 eee 2010-03-31 f90 g90 h90 0.ef90 [程式範例]: 原本是想說用 day = day(date) 抓取 day 的值出來再用 last.day 抓取每月最後一天的資料,但是會出現 last.day 沒有 雖然目前用以下方法有做出我想要的 data a_a_last ; Set HW_ret ; by symbol date ; day = day(date); month = month(date); year = year (date); run ; proc sort data = a_a_last out = last ; by symbol month year descending day ; quit ; data a_a_last ; Set last ; by symbol month year ; If day > lag(day) or lag(day) = . then output; Drop day month year ; run ; 但是想問說可不可以用 last.day 或其他更簡潔方法做出 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.115.87.6 ※ 文章網址: http://www.ptt.cc/bbs/Statistics/M.1412133774.A.F50.html
MOONY135: ...簡潔的方法會簡潔到你想哭 10/01 12:01
MOONY135: 用用看 intnx 吧 10/01 12:01