Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The SAS language isn't that good at doing these kinds of things, which are essentially matrix calculations. The DATA step normally processes one observation at a time, though you can carry calculations over using the RETAIN statement. It is possible that you could get a cleaner result than this if you had access to PROC IML (which does matrix calculations natively), but assuming that you don't have access to IML, you need to do something like the following. I'm not 100% sure that it is what you need, but I think it is along the right lines:</p> <pre><code> data try; infile cards missover; input rs t a b c; datalines; 0 600 1 600 0.02514 667.53437 0.1638 2 600 0.2766 724.60233 0.30162 3 610 0.01592 792.34628 0.21354 4 615.2869 0.03027 718.30377 0.22097 5 636.0273 0.01967 705.45965 0.16847 ; run; data try4(rename=(aa=a bb=b cc=c css=cs tt=t vv1=v1 vv2=v2 vv3=v3 vv4=v4 vv5=v5 vv6=v6)); * Construct arrays into which we will read all of the records; array t(6); array a(6); array b(6); array c(6); array v(6,6); array cs(6); * Read all six records; do i=1 to 6; set try(rename=(t=tt a=aa b=bb c=cc)); t[i] = tt; a[i] = aa; b[i] = bb; c[i] = cc; end; * Now do the calculation, which involves values from each row at each iteration; do i=1 to 6; cs[i]=0; do j=1 to 6; v[i,j]=(2.89*(a[j]**2*(1-c[j]))/ ((c[j]+exp(1.7*a[j]*(t[i]-b[j])))* ((1+exp(-1.7*a[j]*(t[i]-b[j])))**2))); cs[i]+v[i,j]; end; * Then output the values for this iteration; tt=t[i]; aa=a[i]; bb=b[i]; cc=c[i]; css=cs[i]; vv1=v[i,1]; vv2=v[i,2]; vv3=v[i,3]; vv4=v[i,4]; vv5=v[i,5]; vv6=v[i,6]; keep tt aa bb cc vv1-vv6 css; output try4; end; </code></pre> <p>Note that I have to construct arrays of known size, that is you have to know how many input records there are. </p> <p>The first half of the DATA step constructs arrays into which the values from the input data set are read. We read all of the records, and then we do all of the calculations, since we have all of the values in memory in the matricies. There is some fiddling with RENAMES so that you can keep the array names t, a, b, c etc but still have variables named a, b, c etc in the output data set.</p> <p>So hopefully that might help you along a bit. Either that or confuse you because I've misunderstood what you're trying to do!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload