However, that is a lot of dummy variables to manually create and keep track of. So, instead of creating dummy variables, I’m using fixed effects. Looking around, I found two ways to use fixed effects in class proc glm and proc surveyreg:

```
proc glm data = table1;
```

class year industry;

model y = x / solution;

run; quit;

proc surveyreg data = table1;

class year industry;

model y = x / solution;

run; quit;

However, I have two questions / confusions:

1) Do I need to include year and industry in the model statement? If I include the year and industry in the model statement, SAS tells me that The X’X matrix has been found to be singular, essentially one or more of my independent variables are the exact same. If I do not include year and industry in the model statement, it works just fine.

2) Is proc glm or proc surveyreg a better way to use fixed effects? They both seem to give different results.

Thanks!

]]>I have the following model

Investment_it=a + b*X_it + c*Treatment_i + d*After_t + e*Treatment_i*After_t + Industry f.e. + error (1)

where “i” is an index for firm, “t” is an index for quarter. “After “is a dummy after 2007. “Treatment” is a dummy for the treated firms and 0 for the control/untreated firms.

Now the variable “Treatment_i” is endogenous and I use 2SLS with an instrumental variable Z_it.

1st stage is:

Treatment_i=a + b* X_it + Z_it + industry f.e. + error (2)

and using then predicted Treatment_i, I re-estimate (1) . In 2SLS the set of explanatory variables in (2) must be same as those in (1). My question is that do I need to use the “After” in (2) since it also shows up in (1)? Thing is that “After” is like

a time fixed effects and Treatment_i is time invariant in (2). Any feedback is greatly appreciated. thanks!

]]>I was trying to use the %IDVOL macro from WRDS but having problems. Could anyone tell me what’s wrong here? Really appreciate your help!

%IDVOL (INSET=crsp , OUTSET=crsp1, DATEVAR=date, RETVAR= ret, FREQ=D, WINDOW=250,STEP=1, MIN=125, MODEL=m);

crsp is the crspa.dsf

Here is the link to the macro: https://wrds-web.wharton.upenn.edu/wrds/research/macros/sas_macros/idvol.cfm

Here is the log:

### DONE!

### MERGING IN THE RISK FACTORS

ERROR 180-322: Statement is not valid or it is used out of proper order.

ERROR: Libref FF is not assigned.

ERROR: File WORK._VOL.DATA does not exist.

### DONE!

8 data _caldates; set _caldates; n+1; if intnx(‘month’,beg_date,0,‘e’)= intnx(‘month’,”&mindate;“d,0,‘e’) then call symput (‘start’,n); if intnx(‘month’,end_date,0,‘e’)= intnx(‘month’,”&maxdate;“d,0,‘e’) then call symput

—————-

77

ERROR 77-185: Invalid number conversion on “&mindate;“d.

8 ! data _caldates; set _caldates; n+1; if intnx(‘month’,beg_date,0,‘e’)= intnx(‘month’,”&mindate;“d,0,‘e’) then call symput (‘start’,n); if intnx(‘month’,end_date,0,‘e’)= intnx(‘month’,”&maxdate;“d,0,‘e’) then call symput (‘finish’,n

—————-

77

WARNING: Apparent symbolic reference MINDATE not resolved.

ERROR: Invalid date/time/datetime constant “&mindate;“d.

WARNING: Apparent symbolic reference MAXDATE not resolved.

ERROR: Invalid date/time/datetime constant “&maxdate;“d.

ERROR 77-185: Invalid number conversion on “&maxdate;“d.

WARNING: The data set WORK._CALDATES may be incomplete. When this step was stopped there were 0 observations and 3 variables.

WARNING: Data set WORK._CALDATES was not replaced because this step was stopped.

### ESTIMATING IDIOSYNCRATIC VOLATILITY

Thanks,

nsjb

My question is the same as the following one.

Currently I have multiple years’ data for multiple firms of the monthly stock returns.

Firm_ID year month return

101 2002 1 0.05

...

101 2014 12 0.03

102 2003 1 0.035

...

102 2007 12 0.045

.....

205 2004 1 0.065

...

If I calculate it by hand then:

annual compounding return=(1+ Ret_month1)*(1+Ret_month2)*(1+Ret_month3)*...*(1+Ret_month11)*(1+Ret_month12)

I found an answer in communities.sas.com as follows:

```
data want;
```

do until (last.year);

set have;

by firm_id year;

if first.year then

compound_ret=1;

compound_ret=compound_ret*(1+return);

end;

run;

I cannot understand the seventh code. I think the code should be: compound_ret=lag(compound_ret) * (1+return).

No matter which code I use, the compound_ret is lagger than the result by summing up these monthly return.

Could you help me? Thank you.

Regards,

Emily

I want to test significance of summed coefficients after regression, and I need the t-statistics of the test.

My code is as follows, but it showed me only f-statistics.

```
proc sort data=mylib2.l_modeldata;
```

key year/ ascending;

run;

proc reg outest=mylib2.o_m2pooled1 tableout data=mylib2.l_modeldata;

model aar = difepsb difcfpsb epsb cfpsb/noprint ADJRSQ;

run;

test difepsb + epsb = 0;

test difcfpsb + cfpsb = 0;

run;

Could someone help me? Thank you.

Regards,

Emily

I would like to run a regression by firm and year.

(Actually, I am trying to get price nonsynchronicity with market,industry and firm return)

How do I get R square for each firm by year?

For example, the number of firm is 10,000 and year ranges from 1980 to 2010.

Could you plz help me?

Many thanks in advance.

]]>I want to create output table and export it.

How to do that? Could you plz help me?

]]>

I am trying to categorize my data based on constrained and unconstrained firms and I am told to use WW and SA indices to rank firms based on their financial constraint. Usually people use the following equations to estimate these indices:

Whited-Wu (2006) index = -0.091*Cash flow + 0.062*Dividend dummy + 0.021*Long-term debt - 0.044* Size + 0.102* Industry sales growth - 0.035* Sales growth [USING QUARTERLY DATA]

SA (Hadlock and Pierce, 2010) index = (0.737* SA Size) + (0.043*SA Size^2) - (0.040*Age) [USING ANNUAL DATA]

My question is, since WW index is developed using the quarterly data, does it make sense to use it with Compustat annual data?

Regards

]]>Do you know some sas code about how to do simultaneous equations to alleviate the reverse causality? Thanks a lot!

Best,

Xinjiao ]]>

I have an unbalanced panel data containing accounting information on US firms from 1976-2014.

I wish to do the following AR(1) mean-reverting process:

RIR_t,t+tau = RIR_0 (structural level) + w(RIR_t,t+tau-1 - RIR_0)

I have calculated the input series RIR, so i need to do the estimations in SAS, is it even possible? I only have SAS 9.4 and no addons such as sas ET etc.

I don’t wan’t work with a unbalanced panel data, so i wan’t do the estimation each year, only for firms that have data 7 years prior to the estimation date.

I am thinking somekind of do function, that only uses the firms with 7 years of data, each year.

On a side note: I have been trying to do some simple AR(1) models with mean reversion in the proc autoreg function. But can’t seem to model the process like i want.

As we know, proc autoreg;

model y = x, is with an intercept.

What should i do if i want to model y = c + (x-c) ?

Best regards.