LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 4 Mar 2004 11:15:31 -0500
Reply-To:     diskin.dennis@KENDLE.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dennis Diskin <diskin.dennis@KENDLE.COM>
Subject:      Re: Question about "row-level" processing for a dataset
Comments: To: Sober Hi <soberhi@YAHOO.COM>
Content-Type: text/plain; charset="us-ascii"

Sober,

Here's one way:

data prn_exp; merge tuition sch_ship(in=_ss); by person; /* in case there was no SS for this person */ if not _ss then total = 0;

/* amount from scholarsip this year */ pay_ss = min(cost , total); cost=cost-pay_ss; total = total-pay_ss; run;

HTH, Dennis Diskin

Sober Hi <soberhi@YAHOO.COM> Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> 03/04/2004 10:43 AM Please respond to Sober Hi

To: SAS-L@LISTSERV.UGA.EDU cc: Subject: Question about "row-level" processing for a dataset

I am fairly new to SAS so be gently please. I am using SAS 6.12 .

I am trying to figure out how to handle "row-level" processing within a SAS dataset. I think in Oracle/SQL Server, the idea is called a cursor. Perhaps the approach in SAS would be similar.

Here's my scenario. I have the following two datasets (we have them already from elsewhere with the following data).

Dataset TUITION: PERSON YEAR COST DAVE 2004 25 DAVE 2005 30 DAVE 2006 35 DAVE 2007 35 DAVE 2008 40 JOHN 2004 10 JOHN 2005 20 JOHN 2006 25 KIM 2004 15 KIM 2005 10 KIM 2006 0 KIM 2007 25 KIM 2008 50

Dataset SCH_SHIP: PERSON TOTAL DAVE 65 JOHN 75 KIM 80

The relationship between the two datasets: Dave has received $65 in scholarship money (can only be used to reduce his tuition expenses). This is found in the SCH_SHIP dataset. His future tuition expenses are in the TUITION dataset.

So Dave's total tuition expenses are: 25 + 30 + 35 + 35 + 40 = 165

What I need to do is come with a dataset listing of each person's PERSONAL expenses after the accounting for the scholarship money. For example, the COST column for DAVE represents the amount he must personally come up with to cover the cost of tuition. It is safe to assume that a person will first choose to exhaust his/her scholarship money before dipping into their own wallet.

Dataset PRSN_EXP: PERSON YEAR COST DAVE 2004 0 --> tuition is completely covered by scholarship DAVE 2005 0 --> tuition is completely covered by scholarship DAVE 2006 10 --> tuition cost for this year exceeds the remaining scholarship money balance DAVE 2007 35 --> no dedection b/c scholarship money is completely exhausted DAVE 2008 40 --> all scholarship has been exhausted already JOHN 2004 0 JOHN 2005 0 JOHN 2006 0 --> John graduates with a remaining balance in his scholarship fund KIM 2004 0 KIM 2005 0 KIM 2006 0 KIM 2007 0 KIM 2008 20

I am not sure how to handle the processing of deriving this PRSN_EXP dataset from the first two datasets.

I would appreciate any suggestions/advice/pseudo code/articles with similar ideas.

Thanks in advance for your help.


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