<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Combining fixed effects industry dummies with two way clustered standard errors in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Combining-fixed-effects-industry-dummies-with-two-way-clustered/m-p/773918#M37844</link>
    <description>&lt;P&gt;Hello community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I am working on a project with economical penal data. I am trying to replicate a paper in which the author runs a regression with industry dummies and&amp;nbsp;&lt;FONT face="inherit"&gt;standard errors adjusted by a two-dimensional cluster at the firm and year levels. I think I&amp;nbsp;&lt;/FONT&gt;know&lt;FONT face="inherit"&gt;&amp;nbsp;how to include the industry dummies (fixed effect) into my code. I am using the following:&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;proc glm data=&amp;amp;dataset;&lt;BR /&gt;class ff12;&lt;BR /&gt;model &amp;amp;y = &amp;amp;x ff12 /solution ;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;Online I have found one source for two-way clustered&amp;nbsp;&lt;/FONT&gt;standard&lt;FONT face="inherit"&gt;&amp;nbsp;errors which can be found here:&amp;nbsp;&lt;A href="https://sites.google.com/site/markshuaima/home/two-way-clustered-standard-errors-and-sas-code" target="_blank" rel="nofollow noopener noreferrer"&gt;https://sites.google.com/site/markshuaima/home/two-way-clustered-standard-errors-and-sas-code&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;And it looks as follows:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;%MACRO REG2DSE(y, x, firm, time, multi, dataset, output);&lt;/P&gt;&lt;P&gt;proc surveyreg data=&amp;amp;dataset;&lt;BR /&gt;cluster &amp;amp;firm;&lt;BR /&gt;model &amp;amp;Y = &amp;amp;X /covb ;&lt;BR /&gt;ods output covb=firm;&lt;BR /&gt;ods output FitStatistics=fit;&lt;BR /&gt;run;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc surveyreg data=&amp;amp;dataset;&lt;BR /&gt;cluster &amp;amp;time;&lt;BR /&gt;model &amp;amp;Y = &amp;amp;X /covb ;&lt;BR /&gt;ods output covb=time;&lt;BR /&gt;run;quit;&lt;/P&gt;&lt;P&gt;%if &amp;amp;multi=1 %then %do;&lt;/P&gt;&lt;P&gt;proc surveyreg data=&amp;amp;dataset;&lt;BR /&gt;cluster &amp;amp;time &amp;amp;firm;&lt;BR /&gt;model &amp;amp;y = &amp;amp;x /adjrsq covb;&lt;BR /&gt;ods output covb=both ;&lt;BR /&gt;ods output parameterestimates=parm;&lt;BR /&gt;run;quit;&lt;/P&gt;&lt;P&gt;data parm; set parm;keep parameter estimate;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %if &amp;amp;multi=0 %then %do;&lt;/P&gt;&lt;P&gt;/*&lt;FONT color="#FF0000"&gt; &amp;gt;&amp;gt; my attempt&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;proc glm data=&amp;amp;dataset;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;class ff12;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;model &amp;amp;y = &amp;amp;x ff12 /solution ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;ods output acovest=both ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;ods output parameterestimates=parm;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;/*&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&amp;gt;&amp;gt;original code&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;proc reg data=&amp;amp;dataset;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;model &amp;amp;y = &amp;amp;x / adjrsq vif tol hcc acov covb ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;ods output acovest=both ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;ods output parameterestimates=parm;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;run;quit;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;*/&lt;/FONT&gt;&lt;BR /&gt;data both; set both; parameter=Variable; run;&lt;/P&gt;&lt;P&gt;data both; set both;drop variable Dependent Model;run;&lt;/P&gt;&lt;P&gt;data parm; set parm;parameter=Variable;Estimates=Estimate;keep parameter estimates;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;data parm1; set parm;&lt;BR /&gt;n=_n_;m=1;keep m n;run;&lt;/P&gt;&lt;P&gt;data parm1;set parm1;&lt;BR /&gt;by m;if last.m;keep n;run;&lt;BR /&gt;&lt;BR /&gt;data both; set both;&lt;BR /&gt;keep intercept &amp;amp;x;&lt;BR /&gt;run;&lt;BR /&gt;data firm; set firm;&lt;BR /&gt;keep intercept &amp;amp;x;&lt;BR /&gt;run;&lt;BR /&gt;data time; set time;&lt;BR /&gt;keep intercept &amp;amp;x;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data fit1; set fit;&lt;BR /&gt;parameter=Label1;&lt;BR /&gt;Estimates=nValue1;&lt;BR /&gt;if parameter="R-square" then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data fit1; set fit1;&lt;BR /&gt;n=1;&lt;BR /&gt;keep parameter Estimates n;&lt;BR /&gt;run;&lt;BR /&gt;proc iml;use both;read all var _num_ into Z;print Z;use firm;read all var _num_ into X;print X;&lt;BR /&gt;use time;read all var _num_ into Y;print Y;use parm1;&lt;BR /&gt;read all var _num_ into n;print n;B=X+Y-Z;C=I(n);D=J(n,1);E=C#B;&lt;BR /&gt;F=E*D;G=F##.5;&lt;BR /&gt;print B;print G;&lt;BR /&gt;create b from G [colname='stderr']; append from G;quit;&lt;/P&gt;&lt;P&gt;data results; merge parm B ;&lt;BR /&gt;tstat=estimates/stderr;n=0;run;&lt;/P&gt;&lt;P&gt;data resultsfit; merge results fit1;by n;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data &amp;amp;output; set resultsfit;&lt;BR /&gt;drop n;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%MEND REG2DSE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;I have marked my attempt as well as the original code. Could someone please explain to me how I can combine these two issues? &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;Any help is highly appreciated!&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Oct 2021 13:10:17 GMT</pubDate>
    <dc:creator>Orange123</dc:creator>
    <dc:date>2021-10-13T13:10:17Z</dc:date>
    <item>
      <title>Combining fixed effects industry dummies with two way clustered standard errors</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Combining-fixed-effects-industry-dummies-with-two-way-clustered/m-p/773918#M37844</link>
      <description>&lt;P&gt;Hello community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I am working on a project with economical penal data. I am trying to replicate a paper in which the author runs a regression with industry dummies and&amp;nbsp;&lt;FONT face="inherit"&gt;standard errors adjusted by a two-dimensional cluster at the firm and year levels. I think I&amp;nbsp;&lt;/FONT&gt;know&lt;FONT face="inherit"&gt;&amp;nbsp;how to include the industry dummies (fixed effect) into my code. I am using the following:&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;proc glm data=&amp;amp;dataset;&lt;BR /&gt;class ff12;&lt;BR /&gt;model &amp;amp;y = &amp;amp;x ff12 /solution ;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;Online I have found one source for two-way clustered&amp;nbsp;&lt;/FONT&gt;standard&lt;FONT face="inherit"&gt;&amp;nbsp;errors which can be found here:&amp;nbsp;&lt;A href="https://sites.google.com/site/markshuaima/home/two-way-clustered-standard-errors-and-sas-code" target="_blank" rel="nofollow noopener noreferrer"&gt;https://sites.google.com/site/markshuaima/home/two-way-clustered-standard-errors-and-sas-code&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;And it looks as follows:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;%MACRO REG2DSE(y, x, firm, time, multi, dataset, output);&lt;/P&gt;&lt;P&gt;proc surveyreg data=&amp;amp;dataset;&lt;BR /&gt;cluster &amp;amp;firm;&lt;BR /&gt;model &amp;amp;Y = &amp;amp;X /covb ;&lt;BR /&gt;ods output covb=firm;&lt;BR /&gt;ods output FitStatistics=fit;&lt;BR /&gt;run;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc surveyreg data=&amp;amp;dataset;&lt;BR /&gt;cluster &amp;amp;time;&lt;BR /&gt;model &amp;amp;Y = &amp;amp;X /covb ;&lt;BR /&gt;ods output covb=time;&lt;BR /&gt;run;quit;&lt;/P&gt;&lt;P&gt;%if &amp;amp;multi=1 %then %do;&lt;/P&gt;&lt;P&gt;proc surveyreg data=&amp;amp;dataset;&lt;BR /&gt;cluster &amp;amp;time &amp;amp;firm;&lt;BR /&gt;model &amp;amp;y = &amp;amp;x /adjrsq covb;&lt;BR /&gt;ods output covb=both ;&lt;BR /&gt;ods output parameterestimates=parm;&lt;BR /&gt;run;quit;&lt;/P&gt;&lt;P&gt;data parm; set parm;keep parameter estimate;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %if &amp;amp;multi=0 %then %do;&lt;/P&gt;&lt;P&gt;/*&lt;FONT color="#FF0000"&gt; &amp;gt;&amp;gt; my attempt&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;proc glm data=&amp;amp;dataset;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;class ff12;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;model &amp;amp;y = &amp;amp;x ff12 /solution ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;ods output acovest=both ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;ods output parameterestimates=parm;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;/*&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&amp;gt;&amp;gt;original code&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;proc reg data=&amp;amp;dataset;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;model &amp;amp;y = &amp;amp;x / adjrsq vif tol hcc acov covb ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;ods output acovest=both ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;ods output parameterestimates=parm;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;run;quit;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;*/&lt;/FONT&gt;&lt;BR /&gt;data both; set both; parameter=Variable; run;&lt;/P&gt;&lt;P&gt;data both; set both;drop variable Dependent Model;run;&lt;/P&gt;&lt;P&gt;data parm; set parm;parameter=Variable;Estimates=Estimate;keep parameter estimates;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;data parm1; set parm;&lt;BR /&gt;n=_n_;m=1;keep m n;run;&lt;/P&gt;&lt;P&gt;data parm1;set parm1;&lt;BR /&gt;by m;if last.m;keep n;run;&lt;BR /&gt;&lt;BR /&gt;data both; set both;&lt;BR /&gt;keep intercept &amp;amp;x;&lt;BR /&gt;run;&lt;BR /&gt;data firm; set firm;&lt;BR /&gt;keep intercept &amp;amp;x;&lt;BR /&gt;run;&lt;BR /&gt;data time; set time;&lt;BR /&gt;keep intercept &amp;amp;x;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data fit1; set fit;&lt;BR /&gt;parameter=Label1;&lt;BR /&gt;Estimates=nValue1;&lt;BR /&gt;if parameter="R-square" then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data fit1; set fit1;&lt;BR /&gt;n=1;&lt;BR /&gt;keep parameter Estimates n;&lt;BR /&gt;run;&lt;BR /&gt;proc iml;use both;read all var _num_ into Z;print Z;use firm;read all var _num_ into X;print X;&lt;BR /&gt;use time;read all var _num_ into Y;print Y;use parm1;&lt;BR /&gt;read all var _num_ into n;print n;B=X+Y-Z;C=I(n);D=J(n,1);E=C#B;&lt;BR /&gt;F=E*D;G=F##.5;&lt;BR /&gt;print B;print G;&lt;BR /&gt;create b from G [colname='stderr']; append from G;quit;&lt;/P&gt;&lt;P&gt;data results; merge parm B ;&lt;BR /&gt;tstat=estimates/stderr;n=0;run;&lt;/P&gt;&lt;P&gt;data resultsfit; merge results fit1;by n;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data &amp;amp;output; set resultsfit;&lt;BR /&gt;drop n;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%MEND REG2DSE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;I have marked my attempt as well as the original code. Could someone please explain to me how I can combine these two issues? &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="inherit"&gt;Any help is highly appreciated!&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 13:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Combining-fixed-effects-industry-dummies-with-two-way-clustered/m-p/773918#M37844</guid>
      <dc:creator>Orange123</dc:creator>
      <dc:date>2021-10-13T13:10:17Z</dc:date>
    </item>
  </channel>
</rss>

