【问题标题】:Can SAS do as STATA esttab?SAS 可以像 STATA esttab 一样吗?
【发布时间】:2017-05-13 19:35:43
【问题描述】:

STATA 有一个很棒的代码 esttab 可以在一个表中报告多个回归。每列是一个回归,每一行是一个变量。 SAS可以做同样的事情吗?我只能在 SAS 中得到如下所示的东西。不过,表不如esttab漂亮。

提前致谢。

data error;
input Y X1 X2 X3 ;
datalines;
4   5  6  7
6   6  5  9
9   8  8  8
10  10 2 1
4   4 2 2 
6   8 3 5 
4   4 6 7
7   9 8 8 
8   8 5 5
7   5 6 7
9  8 9 8
0 2 5 8
6 6 8 7
1 2 5 4
 5 6 5 8
 6 6 8 9
 7 7 8 2
 5 5 8 2
 5 8 7 8
run;
PROC PRINT;RUN;

   proc reg data=error outest=est tableout alpha=0.1;
M1: MODEL Y =  X1 X2      / noprint;
M2: MODEL Y =  X2 X3      / noprint;
M3: MODEL Y =  X1 X3      / noprint;
M4: MODEL Y =  X1 X2   X3    / noprint;
   proc print data=est;
   run;

【问题讨论】:

  • 请在Stata中使用Esttab时分享输出截图。这会有所帮助。
  • 请描述您想要的输出,并说明它与您从 PROC REG 获得的输出有何不同。

标签: sas


【解决方案1】:

感谢 Praneeth Kumar 的启发。我从http://stats.idre.ucla.edu/sas/code/ummary-table-for-multiple-regression-models/找到了相关信息

我会根据自己的需要进行更改。

/*1*//*set the formation*/
proc format;           
    picture stderrf (round)       
        low-high=' 9.9999)' (prefix='(')                                
            .=' ';                                                  
run;
/*2*//*run the several regressions and turn the results to a dataset*/
ods output ParameterEstimates (persist)=t;                     
 PROC REG DATA=error;
 M1: MODEL Y =  X1 X2    ;
M2: MODEL Y =  X2 X3    ;
M3: MODEL Y =  X1 X3     ;
M4: MODEL Y =  X1 X2   X3   ;
run;                                                                
 ods output close;                                                   

proc print data=t;                                                  
run;
   /*3*//*use the formation and the dataset change into a table*/
proc tabulate data=t noseps;      
  class model variable;                      
  var estimate Probt;     
  table variable=''*(estimate =' '*sum=' '                          
                     Probt=' '*sum=' '*F=stderrf.),                
         model=' '                                                  
          / box=[label="Parameter"] rts=15 row=float misstext=' '; 
run;

【讨论】:

    【解决方案2】:

    我没有使用过Stata,但我知道它是我项目的一部分。不幸的是,没有使用SAS 的好方法。您可以尝试安装和使用最新的Tagsets 以获得所需的输出。 excltags.tpl 在这种情况下应该会有所帮助。

    喜欢,

    ods path work.tmplmst(update) ;
    filename tagset url 'http://support.sas.com/rnd/base/ods/odsmarkup/excltags.tpl';
    %include tagset;
    

    上面安装Tagsets并将其存储在Work中。这不会破坏系统上已安装的标签集。此外,每次打开新的SAS 会话时都需要执行此步骤。

        ods listing close;
        ods tagsets.ExcelXP file='Excelxp.xml';
    #Your Code#
        proc reg data=error outest=est tableout alpha=0.1;
        M1: MODEL Y =  X1 X2      / noprint;
        M2: MODEL Y =  X2 X3      / noprint;
        M3: MODEL Y =  X1 X3      / noprint;
        M4: MODEL Y =  X1 X2   X3    / noprint;
        proc print data=est;
        run;
    #Your Code#
        ods tagsets.ExcelXP close;
    

    我目前在我的家庭桌面上,它没有安装SAS,我也没有尝试过。这应该将回归结果导出到 Excel 中,其中包括系数、显着性水平等。

    让我知道这是否有效。另外,请参阅此Document 了解更多信息。

    【讨论】:

    • 谢谢@Praneeth Kumar。你给我灵感。我想我找到了这个任务的答案。
    猜你喜欢
    • 2021-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-17
    • 2017-11-11
    相关资源
    最近更新 更多