Percentage of SUM statistics from CTABLES

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

Percentage of SUM statistics from CTABLES

Jignesh Sutar
This post was updated on .
I often need to calculate a share of value among different groups in the dataset.

For this I extract the SUM of the values for each of the different groups and then need to take the percentage of each of these total as a % of the grand total (Excel has this functionality with the use of Pivot tables).

But I don't think this can be done directly with CTABLES?

Below is an alternative but I have had to WEIGHT the data as a work around. Is there a more direct way of producing this without needing to compute the additional variables and weights?



Reply | Threaded
Open this post in threaded view
|

Re: Percentage of SUM statistics from CTABLES

Jignesh Sutar
Here is the code and picture I indeed to supply before accidentally posting message:

It's the red cells I am trying to derive directly from the data.



get file="C:\Program Files\IBM\SPSS\Statistics\22\Samples\English\Employee data.sav".


ctables /table (gender)[c] by salary[s][validn'N' sum mean]  /categories variables=gender total=yes /titles title="Table 1".
aggregate outfile=* mode=addvariables /break=gender /SalaryByGenderTotal=Sum(salary) /GenderSplitBase=N.
compute Weight=SalaryByGenderTotal/GenderSplitBase.
weight by Weight.
ctables /table (gender)[c][ucount comma8.0 ucolpct  count comma8.0 colpct ] /categories variables=gender total=yes  /titles title="Table 2".
spssinc modify tables subtype="custom table" select=-1 dimension= columns  level = -1  process = preceding /styles textstyle=bolditalic textcolor=255 0 0.
Reply | Threaded
Open this post in threaded view
|

Re: Percentage of SUM statistics from CTABLES

Jon K Peck
In reply to this post by Jignesh Sutar
How about something like this.

CTABLES
  /TABLE jobcat [C] BY salary [S][SUM, COLPCT.SUM].


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Jignesh Sutar <[hidden email]>
To:        [hidden email]
Date:        01/09/2015 11:58 AM
Subject:        [SPSSX-L] Percentage of SUM statistics from CTABLES
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I often need to calculate a share of value among different groups in the
dataset.

For this I extract the SUM of the values for each of the different groups
and then need to take the percentage of each of these total as a % of the
grand total (Excel has this functionality with the use of Pivot tables).

But I don't think this can be done directly with CTABLES?

Below if an alternative but I have had to WEIGHT the data as a work around.
Is there a more direct way of producing this without needing to compute the
variables and weights?







--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Percentage-of-SUM-statistics-from-CTABLES-tp5728399.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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


===================== 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