Hello everyone,
I am using the aggregate command on the INCOME variable, but instead of aggregating INCOME of all cases I want to do that only for cases whose CMA value is 1. can you please help in doing so? Here is the simplified version of my datasets: INCOME CMA 79 1 54 1 9 1 40 1 20 2 32 2 66 2 53 2 88 2 2 2 Cheers, Hamidreza |
Administrator
|
Is there some reason why you can't just use CMA as a BREAK variable, and then disregard the aggregated values where CMA is not equal to 1? You could set them to some user-defined missing value if you like.
Here's another possibility, which I cannot test right now, because I don't have SPSS on this machine. IIRC (which is not certain), you can use a TEMPORARY-SELECT-IF before the AGGREGATE command. TEMPORARY. SELECT IF (CMA EQ 1). * Your AGGREGATE command here. HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Some commands don't work when TEMPORARY is in affect and I can never remember if AGGREGATE is one of them (perhaps it is RANK that always fails on me?)
But just to prove it does work for AGGREGATE and also demo both the variations Bruce suggests: DATA LIST FREE / INCOME CMA . BEGIN DATA 79 1 54 1 9 1 40 1 20 2 32 2 66 2 53 2 88 2 2 2 END DATA. TEMP. SELECT IF (CMA=1). AGGREGATE OUTFILE=* MODE=ADDVARIABLES /BREAK=CMA /TOTINCOME1=SUM(INCOME). AGGREGATE OUTFILE=* MODE=ADDVARIABLES /BREAK=CMA /TOTINCOME2=SUM(INCOME). COMPUTE TOTINCOME2A=TOTINCOME2. COMPUTE TOTINCOME2B=TOTINCOME2. /* 1. Disaggregate */. IF (CMA=2) TOTINCOME2A=INCOME. /* 2. Or set to sys-missing*/. IF (CMA=2) TOTINCOME2B=$SYSMIS. LIST. INCOME CMA TOTINCOME1 TOTINCOME2 TOTINCOME2A TOTINCOME2B 79.00 1.00 182.00 182.00 182.00 182.00 54.00 1.00 182.00 182.00 182.00 182.00 9.00 1.00 182.00 182.00 182.00 182.00 40.00 1.00 182.00 182.00 182.00 182.00 20.00 2.00 . 261.00 20.00 . 32.00 2.00 . 261.00 32.00 . 66.00 2.00 . 261.00 66.00 . 53.00 2.00 . 261.00 53.00 . 88.00 2.00 . 261.00 88.00 . 2.00 2.00 . 261.00 2.00 . Number of cases read: 10 Number of cases listed: 10 |
Free forum by Nabble | Edit this page |