Hey! I had the same task as mspak. When I used the solution in the post, I was expecting to get an output that would just show residuals for each year within each industry. Instead, SAS calculated a residual for each observation. Is this correct? For the ultimate variable I need to calculate, I need to calculate the standard deviation of my sample firms' residual compared to the corresponding industry residual by year based on all the firms in Compustat. Thus, I need an output from my Compustat data that a residual per each year per each industry. Based on the SAS output this post's solution returned, I have averaged the residuals per industry per year and will use this mean residual to calculate the standard deviation I need. Is this correct, or does anyone have a better solution? Thanks in advance! proc reg data = Reg_Variables noprint; by industry fyear; model chWC_TA=lagCFO_TA CFO_TA leadCFO_TA chREV_TA chPPE_TA/r; output out=Residuals r=residual_x; Run; quit; proc sql; create table Mean as select Industry, fyear, mean(residual_x) as ind_residual from Residuals group by Industry, fyear; quit; proc sort noduplicates; by Industry fyear; where ind_residual ne 0; run;
... View more