I thank Kit for making a command swexp available on SSC.

This command
calculates quantities from a piecewise exponential distribution function defined by the time change(s) and end points listed in time(numlist) with the corresponding survival values of survival(numlist).

Here is an example:
Code:
clear
set obs 1025
gen time=((_n-1)/1024)*8

local tlistA `"0 1(1)4 9"'
local slistA `"1 .8 .6 .4 .2 0.02"'

pwexp time , gen(S) time(`tlistA') sur(`slistA')
pwexp time , gen(lamda) f(lmd) time(`tlistA') sur(`slistA')

pwexp time , gen(S1) rhr(`=2/3') time(`tlistA') sur(`slistA')
pwexp time , gen(lamda1) f(lambda) rhr(`=2/3') time(`tlistA') sur(`slistA') replace

matrix list r(itimeS)

twoway ///
 (line S time, sort lcolor(teal)) ///
 (line S1 time, sort lcolor(green)) ///
 (scatter lamda time, sort yaxis(2) msymbol(o) msize(vtiny) mcolor(teal%100) ) ///
 (scatter lamda1 time, sort yaxis(2) msymbol(o) msize(vtiny) mcolor(green%100) ), ///
 yscale(range(0 1)) ylabel(0(.2)1) ytitle(probabilty) ytitle(lambda,  axis(2)) xscale(range(0 5)) ///
legend(off) scheme(tufte)
Result:
Array