cumulative variable

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

cumulative variable

Keval Khichadia
Hi All,
I have spearate financial aid files for summer fall and spring terms. I added the files together and sorted by id and term to get a picture of how much aid a person recieved each term. The amount of aid is not cumulative, so a person recieved a unique amount of aid each term. I need to make the file cumulative as in the example below.
Original File:
ID  Term            Fund           Amount
 1   Summer     GrantA         10$
 1  Summer      LoanA         20$
 1 Summer       LoanB         30$
 1   Fall                GrantA        10$
 1   Fall               LoanA         20$
 1   Fall               LoanB          30$
 1   Spring         GrantA          10$
 1   Spring          LoanA          20$
 1   Spring          LoanB           30$
 1   Spring          Loan C          50$
I need the result file to look like this:
ID  Term           Fund            Amount
 1   Summer     GrantA         10$
 1     Summer      LoanA         20$
 1     Summer       LoanB         30$
 1      Fall               GrantA        20$
 1      Fall               LoanA         40$
 1      Fall               LoanB          60$
 1      Spring         GrantA          30$
 1      Spring          LoanA          60$
 1      Spring          LoanB           90$
 1       Spring          Loan C          50$
Also, not everyone has aid for summer, fall, and spring. Some have aid only for fall and spring, some only for fall.
I'm pretty sure this can be doen in SPSS, but have no idea where to start. Any help is appreciated.
Thanks,
Keval




====================To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: cumulative variable

Daniel Robertson
Sort by ID, Fund, and Term, then use the lag() function. I think this
syntax should work:

sort cases id fund term.
compute cumAmount = amount.
if(id eq lag(id) and fund eq lag(fund)) cumAmount = sum(amount,
lag(cumAmount)).

Dan R.

> Hi All,
> I have spearate financial aid files for summer fall and spring terms. I
> added the files together and sorted by id and term to get a picture of how
> much aid a person recieved each term. The amount of aid is not cumulative,
> so a person recieved a unique amount of aid each term. I need to make the
> file cumulative as in the example below.
> Original File:
> ID  Term            Fund           Amount
>  1   Summer     GrantA         10$
>  1  Summer      LoanA         20$
>  1 Summer       LoanB         30$
>  1   Fall                GrantA        10$
>  1   Fall               LoanA         20$
>  1   Fall               LoanB          30$
>  1   Spring         GrantA          10$
>  1   Spring          LoanA          20$
>  1   Spring          LoanB           30$
>  1   Spring          Loan C          50$
> I need the result file to look like this:
> ID  Term           Fund            Amount
>  1   Summer     GrantA         10$
>  1     Summer      LoanA         20$
>  1     Summer       LoanB         30$
>  1      Fall               GrantA        20$
>  1      Fall               LoanA         40$
>  1      Fall               LoanB          60$
>  1      Spring         GrantA          30$
>  1      Spring          LoanA          60$
>  1      Spring          LoanB           90$
>  1       Spring          Loan C          50$
> Also, not everyone has aid for summer, fall, and spring. Some have aid
> only for fall and spring, some only for fall.
> I'm pretty sure this can be doen in SPSS, but have no idea where to start.
> Any help is appreciated.
> Thanks,
> Keval
>
>
>
>
> ====================To manage your subscription to SPSSX-L, send a message
> to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>


--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University / irp.cornell.edu

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD