Reputation: 155
I have a variable for "purchase cost" for each case, but I want the total cohort purchase cost (i.e. purchase cost for case 1 + purchase cost for case 2 +...+ purchase cost for case X) combined into a single number.
Is there a specific command to do so in SPSS?
Thanks!
Upvotes: 1
Views: 1495
Reputation: 11310
First, you can calculate the sum of purchase costs across all cases this way:
means purchase_cost/cells = sum.
The sum will appear in the output window.
If, instead, you would like to add a variable to the present dataset, containing the sum of purchase cost, use the aggregate
function:
AGGREGATE
/OUTFILE=* MODE=ADDVARIABLES
/BREAK=
/PC_sum=SUM(purchase_cost).
Finally, if you want a cumulative sum of purchase costs, so that each case contains the sum of purchase costs of all the cases above, use the create csum
command:
create PC_sum=CSUM(purchase_cost).
Upvotes: 1