Hi , I am writing following the piece of code to bootstrap 5000 bi-variate ("Sharpe" "Treynor") sample values from the file 'rsltdspbetach1' from 'mfsas' library. It is working fine. The issue is I have over 100 such 'rsltdspbetach' files i.e. rsltdspbetach2, ....., rsltdspbetach1, rsltdspbetach100. Each have "Sharpe" "Treynor" in them . How to perform it , given the structure ? Macros are not running inside iml loop. i, j etc causing SAs to stop. : proc iml; %let MyData = mfsas.rsltdspbetach1; %let NumSamples = 5000; call randseed(12345); use &MyData; read all var {"Sharpe" "Treynor" } into X; close &MyData; print X; N=nrow(X); C=ncol(X); print N C ; *ndx = SampleReplace(1:N, &NumSamples, N); *Resample from the rows of X. Generate the indices for all bootstrap resamples with a single call; ndx = Sample(1:N, N // &NumSamples) ;*-ndx will be a &NumSamples x N matrix; n_ndx=nrow(ndx); p_ndx=ncol(ndx); print n_ndx p_ndx ; *print (ndx[1:3,1:5]); *print ndx; rho = j(&NumSamples, ncol(X)); *Matrix of 1s.This will be used to hold the results i.e. Y matrices; *print rho; do i = 1 to &NumSamples ; rows = ndx[i, ]; *print rows; Y = X[rows, ]; *print X print Y; *rho [i+ (i-1)*(N-1) : i+ i*(N-1), 1:C] =Y ; *C=ncol(X); c=mean(Y); rho[i,] = c; end; create dspch1_shtr_bts from rho; append from rho; close dspch1_shtr_bts; data mfsas.dspch1_shtr_bts; set dspch1_shtr_bts; run; end; quit ;
... View more