Custom Tables - "Total"

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

Custom Tables - "Total"

SUBSCRIBE SPSSX-JohnF
I am running State By State data, for example row percents of gender and at the bottom of the table is the "Total" for the US if the page contains all 52 States\jurisdictions.  But I can't fit all the States on one page, so I put 26 on page 1 and 26 on page 2, however the total is relative to the States on each page.  My question is, is there an easy way to place the national total at the end of page 1 and page 2?  This is just an easy way to explain my question, well I think its an easy way, as I realize for table this simple all States will fit on one page.  Thanks..........any response will be appreciated.

=====================
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: Custom Tables - "Total"

Jon Peck
I suppose that you are using CTABLES and specifying subtotals after 26 and 52 states.  You can use a post compute to insert the total part way through the group, but you would have to list all the states in the formula.  It would be easier to use STATS TABLE CALC to add the total at a specific point.  I would need to see the actual table and details of exactly what you want to do in order to be more specific.  If you want to send me an spv file with the table, I can work this out.

On Fri, Jul 6, 2018 at 2:18 PM SUBSCRIBE SPSSX-JohnF <[hidden email]> wrote:
I am running State By State data, for example row percents of gender and at the bottom of the table is the "Total" for the US if the page contains all 52 States\jurisdictions.  But I can't fit all the States on one page, so I put 26 on page 1 and 26 on page 2, however the total is relative to the States on each page.  My question is, is there an easy way to place the national total at the end of page 1 and page 2?  This is just an easy way to explain my question, well I think its an easy way, as I realize for table this simple all States will fit on one page.  Thanks..........any response will be appreciated.

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


--
Jon K Peck
[hidden email]

===================== 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: Custom Tables - "Total"

Ki Park
This is not a perfect solution, but you could adapt this code. The key
element is the PCOMPUTE to create a 'new total' after 26 states. For states,
I have the numbers 1 to 52, but you will need to use your own labels.

* Custom Tables.
CTABLES
  /VLABELS VARIABLES=States GenderIM DISPLAY=LABEL
  /PCOMPUTE &cat1 =  EXPR(TOTAL)
  /PPROPERTIES &cat1 LABEL = "Total_national" FORMAT=COUNT F40.0
HIDESOURCECATS=NO
  /TABLE States BY GenderIM [ROWPCT.VALIDN ' Valid  %' PCT40.1]
  /CATEGORIES VARIABLES=States [1.00, 2.00, ..., 26.00, &cat1, 27.00, ...,
52.00]
    EMPTY=INCLUDE TOTAL=YES POSITION=AFTER
  /CATEGORIES VARIABLES=GenderIM ORDER=A KEY=VALUE EMPTY=INCLUDE.

This code will create a single table with 2 totals. In Word doc, you will
need to split the table into 2. Unless Jon help us to split this before
exporting with an OMS.







--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: Custom Tables - "Total"

Jon Peck
You can do a little better like this if the state ids are numeric.

CTABLES
  /PCOMPUTE &cat1 = EXPR(SUBTOTAL)
  /PPROPERTIES &cat1 LABEL = "grand total" FORMAT=COUNT F40.0 
  /TABLE educ [COUNT F40.0]
  /CATEGORIES VARIABLES=educ [LO THRU 26, &cat1, 27 THRU HI SUBTOTAL="Grand Total"] EMPTY=INCLUDE 
    TOTAL=NO.

Or you can do this by position in the EXPR keyword.

On Fri, Jul 6, 2018 at 3:01 PM Ki Park <[hidden email]> wrote:
This is not a perfect solution, but you could adapt this code. The key
element is the PCOMPUTE to create a 'new total' after 26 states. For states,
I have the numbers 1 to 52, but you will need to use your own labels.

* Custom Tables.
CTABLES
  /VLABELS VARIABLES=States GenderIM DISPLAY=LABEL
  /PCOMPUTE &cat1 =  EXPR(TOTAL)
  /PPROPERTIES &cat1 LABEL = "Total_national" FORMAT=COUNT F40.0
HIDESOURCECATS=NO
  /TABLE States BY GenderIM [ROWPCT.VALIDN ' Valid  %' PCT40.1]
  /CATEGORIES VARIABLES=States [1.00, 2.00, ..., 26.00, &cat1, 27.00, ...,
52.00]
    EMPTY=INCLUDE TOTAL=YES POSITION=AFTER
  /CATEGORIES VARIABLES=GenderIM ORDER=A KEY=VALUE EMPTY=INCLUDE.

This code will create a single table with 2 totals. In Word doc, you will
need to split the table into 2. Unless Jon help us to split this before
exporting with an OMS.







--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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: Custom Tables - "Total"

SUBSCRIBE SPSSX-JohnF
In reply to this post by SUBSCRIBE SPSSX-JohnF
Perhaps my approach is wrong, however it seems to me that if you have 52 states\jurisdictions data and I want Alabama through Missouri in Table 1 with a total at the bottom representing Alabama through Puerto Rico (all 52), regardless of the code used, once I use the "Temporary select if State le 29" the code can only work with data from Alabama and Missouri or is there a way for the code to use all of the data and only present Alabama through Missouri in the table?

Thanks.......Any thoughts would be appreciated.

29 is Missouri's 2 digit FIPs code.

=====================
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: Custom Tables - "Total"

Jon Peck
Apart from the solution I posted using STATS TABLE CALC, you could use AGGREGATE to create a dataset with the total(s) for all the states; match that back into the main dataset as a new continuous variable, and include that variable in your CTABLES code that you run with your temporary select.

On Tue, Jul 10, 2018 at 10:11 AM SUBSCRIBE SPSSX-JohnF <[hidden email]> wrote:
Perhaps my approach is wrong, however it seems to me that if you have 52 states\jurisdictions data and I want Alabama through Missouri in Table 1 with a total at the bottom representing Alabama through Puerto Rico (all 52), regardless of the code used, once I use the "Temporary select if State le 29" the code can only work with data from Alabama and Missouri or is there a way for the code to use all of the data and only present Alabama through Missouri in the table?

Thanks.......Any thoughts would be appreciated.

29 is Missouri's 2 digit FIPs code.

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


--
Jon K Peck
[hidden email]

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