```Date: Thu, 4 Feb 2010 13:13:47 -0800 Reply-To: ChrisG Sender: "SAS(r) Discussion" From: ChrisG Organization: http://groups.google.com Subject: Re: macro problem Comments: To: sas-l@uga.edu Content-Type: text/plain; charset=ISO-8859-1 On 4 fév, 16:11, chang_y_ch...@HOTMAIL.COM (Chang Chung) wrote: > On Wed, 3 Feb 2010 12:17:17 -0800, Tom Abernathy > wrote: > ...>Next exercise is it to eliminate the macro completely and just code it > >using arrays. > > ... > > Hi, Chris, Here is one way. HTH. Cheers, Chang > > /* test data */ > data one; > input t spread libor; > cards; > 1 10 0.1 > 2 20 0.1 > 4 10 0.2 > ; > run; > > /* chris */ > data chris; > set one; > if t>0 then d0=spread/((1+libor)**t); else d0=0; > if t-1>0 then d1=spread/((1+libor)**(t-1)); else d1=0; > if t-2>0 then d2=spread/((1+libor)**(t-2)); else d2=0; > if t-3>0 then d3=spread/((1+libor)**(t-3)); else d3=0; > run; > > /* chang -- assuming an integral t from a range [0,3] */ > data chang; > set one; > array d[0:3] d0-d3 (4*0); > do i = 0 to 3 while (t > i); > d[i] = spread/(1+libor)**(t-i); > end; > drop i; > run; > > /* check */ > proc compare base=chris compare=chang; > run; > /* on log > NOTE: No unequal values were found. All values compared are exactly equal. > */ Hi Thanks for your input i will test it tomorrow on the data at work cheers CG ```

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