Re: [問題] sas 的merge問題

看板Statistics作者 (歐吉桑留學生)時間15年前 (2008/09/10 21:24), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/3 (看更多)
※ 引述《chinmantic (冬去春來秋又過)》之銘言: : data test; : set aa; : proc sort out=a; : by id; : run; : data test2; : set bb; : proc sort out=b; : by id; : run; : data new; : set b a; : merge a(in=ina) b(in=inb); : by id; : if a and inb then output ; ^^^ : run; : LOG檔為: : NOTE: Variable a is uninitialized. ^^^^^^^^^^^ 姑且不論是否要寫成  data new merge a b... 1.請學會看log a==>改成ina 2. then output 可以省了 2.寫這麼長 又兩個sort 又產生出a b這兩個暫存檔.. 建議用SQL寫 Proc SQL; select a.a1, a.a2, a.ina ..., b.b1,b.b2, b.inb .. from a, b where a.ina=b.inb ;quit; 你寫成16行 扣除Proc 以及quit 我只寫三行 而且沒有暫存檔 不必再去下proc delete -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.167.185.98

09/11 02:20, , 1F
我看到原PO有87個變項,就無所謂用哪種方法了
09/11 02:20, 1F
文章代碼(AID): #18nygedm (Statistics)
文章代碼(AID): #18nygedm (Statistics)