[問題] sas巨集跑的結果錯誤已刪文

看板Statistics作者 (小鼻子小眼睛)時間5年前 (2021/01/04 16:38), 5年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
因為需要跑許多回歸,所以將程式碼寫成巨集,但寫成巨集後的係數卻會與沒有利用集巨的結果差異極大。 想請教各位版友幫忙看看是哪裡出了問題,拜託大家了! 這個問題困擾我好久但解決不了 以下是程式碼與結果差異,皆是控制產業與年度固定效果 單純迴歸的程式碼與結果 %let depvar=Tobins_Q;/*應變數*/ %let reglist=lag_GFI1 ;/*變數*/ %let class= year ind ;/*控制與否*/ %let n=%eval(%sysfunc(countw(&reglist))+1);/*變數數量加一*/ proc surveyreg data=all; class &class; model &depvar=&reglist &class/solution adjrsq; ods output ParameterEstimates=pest1; ods output FitStatistics=fit1 DataSummary=obs1 ClassVarInfo=classinfo; quit; run; data param2; length coef $13.;/*設定係數長度*/ set pest1; if _n_<=&n;/*看要前幾個*/ if probt<0.1 then p='* '; if probt<0.05 then p='** '; if probt<0.01 then p='***'; coef=put(estimate, 9.4)||p;/*小數點後揭露4 位*/ t='('||put(tvalue,7.2)||')'; stderr='('||put(stderr,7.2)||')'; order=_n_; keep order Parameter coef t; rename Parameter=variable; run; proc sort data=param2; by order variable; run; proc transpose data=param2 out=out1; by order variable; var coef t; run; data obs2; set obs1; if label1='Number of Observations'; label='Obs'; call symput('obs',cvalue1); col1=put(cValue1,12.0); rename label=variable ; keep label col1; run; data fit2; set fit1; if label1='Adjusted R-Square'; col1=put(nvalue1,9.4); rename label1=variable ; keep label1 col1; run; data mmm1; set out1 obs2 fit2; run; proc print; run; 迴歸結果如圖https://imgur.com/ZddC0ti
為求方便我將以上程式碼直接複製建立巨集只有改最前面與結尾的匯出部分 %macro surveyreg(depvar,reglist,class,infile,outfile); %let n=%eval(%sysfunc(countw(&reglist))+1);/*中有的變數數量加一*/ proc surveyreg data=&infile; . . . data &outfile; set out1; drop order ; run; quit; %mend surveyreg; 明明幾乎直接複製但出來的結果卻差很多,如圖https://imgur.com/Ctac3zi
樣本的個數也都一樣但不知道為什麼結果會差那麼多,拜託大家幫忙了! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.72.71.164 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Statistics/M.1609749503.A.24F.html ※ 編輯: s564978 (42.72.71.164 臺灣), 01/04/2021 16:42:54
文章代碼(AID): #1VyjF_9F (Statistics)