proc iml ; /*Create, format and print transition matrix*/ varNames = {'InitialState' 'M1' 'R1' 'Exit'} ; trans = {0 0.65 0.3 0.05, 0 0.92 0.04 0.04, 0 0.95 0.03 0.02, 0 0 0 1} ; mattrib trans colname=varNames rowname=varNames format=percent8. ; print (trans) ; /*Create input matrix*/ input1 = shape({1}, 1, ncol(trans), 0) ; mattrib input1 colname=varNames rowname=('period1':'period1000') ; print input1 ; /*****************************/ /*Create forecase of movement*/ /*****************************/ /*Set number of forecast months*/ ForecastMonths = 100 ; /*Initialise results matrix*/ results = input1 // j(ForecastMonths, ncol(trans), 0) ; /*DO loop solution*/ do i = 2 to ForecastMonths ; results[i, ] = input1 * trans**i ; end ; /*Output results - forecast matrix*/ print (results) [colname = varNames format=percent10.2]; /*Vectorized way?*/ quit ;