*** This program uses a data step to create the first column of random data with &Cols observations, then uses a macro do-loop to add the remaining columns based on the values from each consecutive column. *** /* This step creates the first column (Col_1) of your Loss_Triangle table, where &Cols is the number of observations. So macro &Cols is kind of like data-step _n_. */ DATA Loss_Triangle; DO n = 1 to &Cols.; Col_1 = 10000*(1+UNIFORM(_n_)); * assigning random values based on the _n_ observation counter; OUTPUT; END; RUN; /* This step creates the rest of the columns based on the values of the first column. */ DATA LOSS_TRIANGLE; SET LOSS_TRIANGLE; * setting initial table with one column of random data; %DO s=1 %TO &Cols. - 1; * s-counter goes through observations, it is a macro variable, even though no ampersand; %LET x = %EVAL(&Cols. - &s. + 1); * x checks the distance between s and t, so that last calculation is at at second-to-the-last observation (that leaves room for t = EVAL(&s + 1)); %LET t = %EVAL(&s. +1); * t is one observation number ahead of the s-counter, first value of t is 2, it also numbers new columns; IF &x. > _n_ THEN * from the first data part, data-step _n_ is like macro variable &Cols., so &x = _n_ when s=1, this says to skip Col1 that's already there; Col_&t. = Col_&s. * RAND("UNIFORM", (1/&t.)**0.5, (1 / &t.)**0.1); * first column Col_2 calculated from Col_1, Col_3 on Col_2 and so on; ELSE col_&t. = .; * this is the loss part of the loss triangle; %END; RUN;
... View more