Hello Guys,
I am conducting an event study (dividend announcements) with 109 companies and an event window -5/+5 and estimation window of 180.
As I am new to Stata, I have done my analysis after long hours but now I am struggling with presenting my output in a nice table.
I want it to look like the uploaded pictures (2&3).

I am using the following code:

Sorting Data & Predicting Normal Return
Code:
 use "eventdates.dta", clear  
 joinby company_id using "stockdata.dta"  
 egen group_id = group(company_id event_date)  
 save "data2useRP.dta", replace  
 use "data2useRP.dta", clear  
    
 sort company_id date  
 by company_id: gen datenum=_n  
 by company_id: gen target=datenum if date==event_date  
 egen td=min(target), by(company_id)  
 drop target  
 gen dif=datenum-td    
 by company_id: gen event_window=1 if dif>=-5 & dif<=5  
 egen count_event_obs=count(event_window), by(company_id)  
 by company_id: gen estimation_window=1 if dif<-6 & dif>=-185  
 egen count_est_obs=count(estimation_window), by(company_id)  
 replace event_window=0 if event_window==.  
 replace estimation_window=0 if estimation_window==.  
 keep if event_window | estimation_window    
 set more off  
 gen predicted_return=.  
 egen id=group(company_id)  
 forvalues i=1(1)109 {  
         l id company_id if id==`i' & dif==0  
         reg ret market_return if id==`i' & estimation_window==1  
         predict p if id==`i'  
         replace predicted_return = p if id==`i' & event_window==1  
         drop p  
 }
AR, CAR, AAR, CAAR & t-test
Code:
  
 sort id date  
 gen abnormal_return=ret-predicted_return if event_window==1  
 by id: egen cumulative_abnormal_return = total(abnormal_return)  
    
 sort id date  
 by id: egen ar_sd = sd(abnormal_return)  
 gen test =(1/sqrt(11)) * ( cumulative_abnormal_return /ar_sd)  
 list company_id cumulative_abnormal_return test if dif==0  
    
 sort dif  by dif: egen AAR = mean(abnormal_return)  
 bysort company_id (dif): gen CAAR = sum(AAR)    
 sort dif  by dif: egen AAR_sd = sd(abnormal_return)  gen AAR_test =(sqrt(109)) * (AAR /AAR_sd)   
  
 sort dif  by dif: egen CAAR_sd = sd(cumulative_abnormal_return)  gen CAAR_test =(sqrt(109)) * (CAAR /CAAR_sd)  
Now I want to have my output as the pictures I have uploaded. I think I have to use a loop and outreg2. However, after long trials I don't get the tables that I have uploaded.
I would really appreciate it, if you can help me on this task.

Thank you a lot.

Bernd Eber