Two-way fixed effects are easily coded up using the inefficient dummy method. Since we're trying for efficiency, a better solution is to use a combination of the Frisch-Waugh Theorem and the inefficient method.

Explicitly, first determine which one of your dummy sets has fewer elements.

Suppose we want to run the regression in the previous subsection -- returns on lagged size -- with dummies for date and permno. Since data is monthly and the msf file has data from 1927-2007, there will be 12*81=810+162=972 date dummies. That's much smaller than the 27865 permno dummies.

Then we create the date dummies as shown in Section 13.3.1. Explicitly:

data dates; date='31Jan1927'd; do while(date<='31Dec2007'd); output; date=intnx('month', date+1, 1)-1; end; run; data dates; set dates; array dateids (972); do i = 1 to dim(dateids); dateids(i)=0; end; dateids(_n_)=1; run;

and merge these in with the original dataset by date. There are 972 date dummies named dateid1-dateid972.

Once I have the date dummies, I treat the date dummies as additional independent variables:

proc standard data= msf mean=0; by permno; var lagsize dateid1-dateid972; run; proc reg data=msf; model ret=lagsize dateid1-dateid972/noint; run;

which produces the two-way fixed effects coefficient on lagsize.

To suppress the printing of the dummy coefficients, I can say:

proc reg data=msf outest=est(keep=lagsize _type_) noprint tableout; model ret=lagsize dateid1-dateid972/noint; run; proc print data=est; run;