
********************************************************************;
*																	;
*		PROGRAM CREATED BY MIKAEL BERGBRANT 2010					;
*																	;
*		Creating Tstats with PROC REG								;
*																	;
*This program was created due to the limitations of the OUTEST		;
*option in PROC REG. The additional Model option '/OUTSEB' allows	;
*users to get the standard deviations for the estimated parameters.	;
*However, they appear on a seperate line. This could be taken care	;
*of easily when only running one regression, but for several		;
*regressions it could be tedious. This program attempts to make it	;
*simple.															;
*Another option to using this program is to use ODS Output.			;
*Unfortunately, this is not efficient when running many regressions	;
*																	;
*Copyright bergbrant.com 2010										;
*																	;
********************************************************************;

%macro create(List);
proc datasets nolist nodetails;
	delete estout;
quit;

%do i=1 %to 36;
PROC REG DATA=zmacro Outest=est;
Model VAR&i==A B C /OUTSEB;
run;

Data est; set est; 
Model=&i;
run;

PROC APPEND BASE=estout FORCE DATA=est;
run;
 %end;
%mend create;
%create(3)

*This datastep seperates the datasets containing parameter estimates and those containing standard errors;
Data estout1; set estout;
If _TYPE_='PARMS';
run;
Data estout2; set estout;
If _TYPE_='SEB';
RENAME Intercept=sIntercept;
RENAME A=sEST;	*Need to rename each one of the variables included;
RENAME B=sEST2;
RENAME C=sEST3;
run;
PROC SQL;
	Create Table estout as
		select i.*, j.sIntercept, j.sEST, j.sEST2, jEST3 
			from estout1 as i LEFT JOIN estout2 as j
				on i.MACRO = j.MACRO;
Quit;
Data estout; set estout;
tstatEST=EST/sEST;
tstatEST2=EST2/sEST2;
tstatEST3=EST3/sEST3;
run;
