*copy data to the running directory; %MACRO runsim(i); data temp; number = &i; datastr=put(number, 4.); datastrcomp=compress(datastr,''); commd ='cp /pscratch/zzhang4/Private/student-grm/data/TdataLinear/DATAN500I'||datastrcomp||'bugs.txt data.txt'; run; data _null_; set temp; file 'cp.sh'; put commd; run; data _null_; X 'chmod 755 cp.sh'; X './cp.sh'; X 'rm -f cp.sh'; run; quit; *copy coda to the results locations; data temp1; r1 = &i; rstr=put(r1, 4.); codar=compress(rstr,''); commd1 = 'mv codaCODAchain1.txt /pscratch/zzhang4/Private/student-grm/CODA/folder/DATACODANcodansI'||codar||'.txt'; commd2 = 'mv out.txt /pscratch/zzhang4/Private/student-grm/CODA/folder/DATACODANcodansI'||codar||'dic.txt'; run; data _null_; set temp1; file 'coda.sh'; put@1 '/pscratch/zzhang4/Private/OpenBUGS307/bin/OpenBUGS.sh < script.txt > out.txt'; put commd1; put commd2; put "rm -f data.txt"; put "rm -f codaCODAindex.txt"; put "rm -f cp.sh"; run; data _null_; X 'chmod 755 coda.sh'; X './coda.sh'; X 'rm -f coda.sh'; run; quit; %MEND runsim; %MACRO batch; %LET r=1001; %DO %WHILE (&r <=1100); %runsim(&r); %LET r = %eval(&r+1); %END; %MEND batch; %batch;