Click here to Skip to main content
14,421,160 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi!

I would like to convert the below SAS code into R code. It would be great help for me!
Thanks in advance!

%let NN=1000;
proc iml;
cov={1 .1 .1 .1 .1,
.1 1 .1 .1 .1,
.1 .1 1 .1 .1,
.1 .1 .1 1 .1,
.1 .1 .1 .1 1
};
M=5;
h={[5].2};
Rcvr={[5].2};
T={[&NN]0};
VL={[&NN]0};
VR={[&NN]0};
s={[&NN]0};
r=0.05;
rv=rannor(repeat(1200,&NN,5));
Y=rv*(root(cov));
spread=0;
i=1;
j=1;
do while (i<=&NN);
do while (j<=5);
x=cdf('Normal',Y[i,j]);
Y[i,j]= -(log(1-x))/h[j];
j=j+1;
end;
T[i]=min(Y[i,]);
j=1;
k=0.5;
do while (k<T[i] & k<=M);
VL[i]=VL[i]+EXP(-r*k);
k=k+0.5;
end;
do while(j<=5);
if (T[i]=Y[i,j] & T[i]<M) then VR[i]=VR[i]+(1-Rcvr[j])*(EXP(-r*T[i]));
j=j+1;
end;
j=1;
if VL[i]^=0 then s[i]=VR[i]/VL[i];
spread=spread+s[i];
i=i+1;
end;
spread=spread/&NN;
print spread;
run;
quit;

What I have tried:

I stucked in some steps in my effort to translate the code
Posted
Updated 26-Apr-18 0:09am
Comments
Richard MacCutchan 26-Apr-18 5:01am
   
Sorry, this site does not provide code, or code conversion, to order.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

We do not provide a code conversion service, and code conversion rarely produces good code in the target language anyway: either learn SAS plus R and convert it yourself, work out what the SAS code is doing and recode that functionality in R, or find R code that does the same job.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100