I have a doubt about determining safety stock when the demand and lead time are variable, the data to determine the mean and standard deviation must be only with historical data? It's not possible apply forecasted demand? For example a mix of 15 months of historical data and 10 months of forecasted demand

vermorel 3 months | flag

You will find a safety stock calculation, with varying lead times, at:

The web page includes an illustrative Excel sheet to let you reproduce the calculation.

However, the bottom line is: safety stocks are a terrible model. See:

As a statistical answer, they are completely obsolete. Probabilistic forecast must be favored instead.

15 months of historical data is ok-ish, it's a bit tricky to assess seasonality with less than 2 years, but it can be done as well.

Hope it helps,