LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 23 Jun 2005 03:10:48 -0400
Reply-To:   Paul <psquares@YAHOO.COM.AU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Paul <psquares@YAHOO.COM.AU>
Subject:   Array problem

Hi SAS users

Many Thanks for helping me out in my last post.

I have a tricky programming problem that I would like to ask.

Not sure if using array will be a better option here here it's.

Attach is a data set where we have account number and debt outstanding due in number of days (current due -- 150 days).

accno Curr_due 30Days 60Days 90Days 120Days 150day last_val

153553 0.18 0 0 0 0 0 0.18 167743 0 0 0 0 0 0.26 0.26 198358 0 0.4 0 0.13 0 0 0.13 451646 0 0 0 0 0.66 0 0.66 477051 0 0 3.6 3.83 0 0 3.83 1106116 0 0 289.9 0 0 0 289.9

The aim is to create a last_val column where it will search thru all the current_due--onefifty_days horizontally and look for the last value that is not zero for each accno and place that value in the last_value column. Sound simple but I having problem programming it.

Below is part of my working to achieve this but it proving more difficult than I first thought. I need to have a stopping criteria that will stop the array from looping if it found the last debt aging variable.

Say

accno i debt_aging 153553 1 0.18 153553 2 0 153553 3 0 153553 4 0 153553 5 0

then the loop will stop at i=1 and put 0.18 in the last_val column.

libname tmp 'C:\';

data dataIn(keep = accno thirty_days sixty_days ninety_days onetwenty_days onefifty_days); set tmp.paul; run;

data Array_1(keep = accno myTestVar i); set dataIn; array testArray (5) thirty_days sixty_days ninety_days onetwenty_days onefifty_days; do i = 1 to 5; myTestVar = testArray(i); if myTestVar > 0 then output; end; run;

data array_2(keep = accno myTestVar i); set dataIn; array testArray (5) thirty_days sixty_days ninety_days onetwenty_days onefifty_days; do i = 1 to 5; myTestVar = testArray(i); output; end; run;

Not sure if array is the best way to go about solving this problem, but any suggestion is most welcome.

Many Thanks in advance

Best Regards

Paul


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