Thank you very much Reeza. It worked out well. Now I am trying to automate the process by using functions like arrays, but I am having a bit of trouble. I want it to go from t=0 to t=9 for variabes A and L. For the Y variables, I would like it to go from t=1 to t=10.Could you provide some guidance. Data sim; Call streaminit(234); array A{0:9} A0-A9; array L{0:9} L0-L9 ; array Y{1:10} Y1-Y10; do id = 1 to 100; do t=0 to 1; U = rand("normal",0, 0.25); L{0} = rand("normal", 5.5 + U, 0.04); A{0} = rand("Bernoulli", expit(5 - L{0})); L{1} = rand("normal",0.9*L{0} + A{0} + 0.1*U, 0.01); A{1} = rand("bernoulli", expit(A{0} + 4.5*L{1})); Y{1} = rand("bernoulli", expit(-8 + L{0} - 0.3*(A{0}) - U)); end; do t=2 to 8; if (Y{t-1}=0) then do; L{t} = rand("normal",0.9*L{t-1} + A{t-1} + 0.1*U, 0.01); A{t} = rand("bernoulli", expit(A{t-1} + 4.5*L{t})) ; Y{t} = rand("bernoulli", expit(-8 + L{t-1} - 0.3*sum(of A{0} to A{t-1}) - U)); end; else do L{t}=.; A{t}=.; Y{t}=.; end; end; t=9; if (Y{t}=0) then do; Y{t+1} = rand("bernoulli", expit(-8 + L{t} - 0.3*sum(of A{0} to A{t}) - U)); end; else do Y{t+1}=.; end; output; end; run;
... View more