Hi everyone,
I am new to Stata and I am using it to analyze data for my Bachelor thesis. I have a dataset containing monthly returns for stocks (Ri), risk-free rates (Rf) and market returns (Rm) in the last 5 years roughly (2017-2022)
I am currently trying to compute market betas by running the following regression (from Capital Asset Pricing Model):

(excess return on stock i) = alpha_i = beta_i (market excess return) + error term_i

where 'excess return on stock_i’ = stock_exc_ret = Ri - Rf and
'market excess return’ = market_exc_ret = Rm - Rf
I want to compute the beta of the above regression for the same firm (identified by gvkey) across 2017-2022. I used the following approach:

rangestat (reg) stock_exc_ret market_exc_ret, by(gvkey) interval(year . .)

however I get beta values (b_market_exc_ret) that are unreasonable and unacceptable from a theoretical viewpoint. (e.g. the mean is 345 while it should be around 1). does anyone have some suggestion on why this is the case?

I leave here a sample of the dataset
datadate month_ret_vol stdret gvkey year stock_exc_ret market_exc_ret reg_nobs reg_r2 reg_adj_r2 b_market_exc_ret b_cons se_market_exc_ret se_cons
31jan2017 5.093794 5.093794 1004 2017 -2.980691 .0175263 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401
28feb2017 5.093794 5.093794 1004 2017 7.59576 .0368343 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401
31mar2017 5.093794 5.093794 1004 2017 -2.29553 -.0007422 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401
30apr2017 5.093794 5.093794 1004 2017 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401
31may2017 5.093794 5.093794 1004 2017 -2.918091 .0109622 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401
30jun2017 5.093794 5.093794 1004 2017 -.5157859 .0041968 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401
31jul2017 5.093794 5.093794 1004 2017 7.80998 .0186268 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401
31aug2017 5.093794 5.093794 1004 2017 -3.583715 -.0002805 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401
30sep2017 5.093794 5.093794 1004 2017 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401
31oct2017 5.093794 5.093794 1004 2017 3.13574 .0213482 42 .42950937 .4152471 183.64449 -2.0490518 33.464616 1.6615401

Apologies for the non-technical language.