Hi,
I have spent my last week trying to find the problem. It turns out the change of streaminit(1234) doesn't help.
I tried to find the common problem when the loop breaks. The error occurs when the iSample = 24001, 45501, 72001,124001,194001... I have thought that it should be the problem of the data, but if I started another run from 24001 etc it can still run and break at another point.
And I have also found another interesting point that at each error the program outputs a gibbsout file with exactly 13962 rows of data. So I am wondering could it be some running limit of RAND function (each time the log points to the problem of rand) or something?
I pasted here the code of the main loop to make you see the picture.
*____________________________________________________________________________________________________
This proc loops over all samples, calling the estimation routines.
_____________________________________________________________________________________________________;
options nonotes;
proc iml;
start main;
call streaminit(1234);
reset storage=this.imlstor; * This contains the subroutines built in RollGibbsLibrary02.sas;
load;
reset printadv=1 log;
use temp.pys;
read all var {permno year kSample} where(nTradeDays>=60) into sample [colname=colSample]; *my correction;
nSamples = nrow(sample);
print 'nSamples=' nSamples;
permno = sample[,1];
year = sample[,2];
kSample = sample[,3];
outSet = j(1,7,.);
varnames ={'permno','year','kSample','c','beta','varu','sdu'};
create this.gibbsOut from outSet [colname=varnames];
do iSample=166001 to nSamples;
thisPermno = permno[iSample];
thisYear = year[iSample];
thisKSample = kSample[iSample];
if mod(iSample,500)=1 then do;
t = time();
ctime = putn(t,'time.');
print ctime iSample '/' nSamples ': ' thisPermno thisYear thisKSample;
end;
if thisPermno>=&startPermno & thisYear>=1990 then do;
use temp.dsf where (permno=thisPermno & year=thisYear & kSample=thisKSample);
read all var {p pm q} into x [colname=colx];
nSweeps = 1000;
regDraw = 1;
varuDraw = 1;
qDraw = 1;
nDrop = 200;
call RollGibbsBeta(parmOut, x[,1],x[,2],x[,3], nSweeps, regDraw, varuDraw, qDraw, 0,0,0,0);
p2 = parmOut[(nDrop+1):nSweeps,];
p2 = p2 || sqrt(p2[,3]);
pm = p2[+,]/(nSweeps-nDrop);
outset = thisPermno || thisYear || thisKSample || pm;
*print outset;
setout this.gibbsOut;
append from outSet;
end;
end;
finish main;
run;
quit;
Thanks again for your help.
Best,
Tammy