I am a beginner SAS user. In this simulation, there is an initial value of the variable called "p", but there will be a new value (called "newp" in code below") calculated by SAS for each iteration in the simulation. How can I get this value that is created in each iteration to be used in the iteration that follows? See code below. That is, when gen=1, the value of "p" is 0.00005. Based on the results of the simulation a "newp" will be calculated using the entered formula. This "newp" should be used for gen=2, where again, another different "newp" is calculated and should be used in gen=3, and so forth. data a; do gen=1 to 10; seed=47639087; expon=2*ranuni(seed) + 4; n=round(10**expon,1); p=.00005; q=1-p; NumRR = round(n*p*p,1); NumSR = round(2*n*p*q,1); NumSS = round(n*q*q,1); newp=(NumRR + .5*NumSR) / (Numrr + numsr + numss); diffp=p-newp; newq=(NumSS + .5*NumSR)/ (Numrr + numsr + numss); diffq=q-newq; output; end;
... View more