Date: Tue, 14 Jan 2003 15:18:04 -0800 Dale McLerran "SAS(r) Discussion" Dale McLerran Re: IML question To: RAHUL CHAHAL <20030114203608.58187.qmail@web14203.mail.yahoo.com> text/plain; charset=us-ascii

Rahul,

I don't see why you have the IF statement in the following code block:

> DO I = 1 TO T; > IF A[I] < 240 THEN DO; > D[I] = X[2,2]#B[I]; > END; > ELSE IF 240 <= A[I] <= 620 THEN DO; > D[I] = X[2,2]#B[I]; > END; > END;

The result D[I] is computed the same way regardless of whether A[I]<240 or 240<=A[I]<=620. Why not just:

DO I = 1 TO T; IF A[I]<=620 THEN DO; D[I] = X[2,2]#B[I]; END; END;

Now, to stack vectors D as then are computed, here is a bit of revised code:

DO J = 1 TO K; X = RANUNI(J(5,5,8101)) ; DO I = 1 TO T; IF A[I]<=620 THEN DO; D[I] = X[2,2]#B[I]; END; IF J=1 THEN D_STACK = D; ELSE D_STACK = D_STACK // D; END;

There are other ways which might be more computationally efficient. However, the above approach should do the job for you.

Dale

--- RAHUL CHAHAL <rahulchahal@YAHOO.COM> wrote: > Hi, I would like to stack the column vector D in all my iterations in > my program that uses PROC IML. I am seeking help. > > Program: > > DATA SORTED; > > INPUT BSCORE TOTBAL TOTINC BAD ; > > CARDS; > > 180 10000 71000 1 > > 200 50000 55000 0 > > 210 15000 64000 0 > > 220 50000 18000 0 > > 230 25000 17000 0 > > 240 10000 99000 0 > > 320 20000 88000 0 > > 350 11000 77000 0 > > 360 12000 44000 0 > > 380 13000 33000 0 > > 420 16000 22000 0 > > 440 21000 11000 0 > > 460 22000 59000 0 > > 480 32000 20000 0 > > 500 35000 25000 1 > > 520 45000 45000 1 > > 540 52000 39000 1 > > 570 27000 19000 1 > > 600 29000 80000 1 > > 620 24000 10000 1 > > ; > > RUN; > > PROC IML; > > RESET LOG; > > USE SORTED; > > READ ALL VAR{BSCORE} INTO A; > > READ ALL VAR{TOTBAL} INTO B; > > READ ALL VAR{TOTINC} INTO C; > > READ ALL VAR{BAD} INTO P; > > PRINT A,B,C,P; > > K = 3; > > T = NROW(A); > > D = J(T,1); > > DO J = 1 TO K; > > X = RANUNI(J(5,5,8101)) ; > > DO I = 1 TO T; > > IF A[I] < 240 THEN DO; > > D[I] = X[2,2]#B[I]; > > END; > > ELSE IF 240 <= A[I] <= 620 THEN DO; > > D[I] = X[2,2]#B[I]; > > END; > > END; > > END; > > > > Thanks in advance. > > > > --------------------------------- > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now

===== --------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

__________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com

Back to: Top of message | Previous page | Main SAS-L page