Dominic Abrams (Professor of Social Psychology, Kent) is currently preparing a 'driver review' for the (UK) Government Office of Science on the topic of social attitudes to ageing in the UK. He has asked me for some analysis of the 1981 European Values Survey on which I worked with his grandfather, the late Dr Mark Abrams, many years ago. Matching up variable names in three different versions of SPSS *.sav files and questionnaires from the same survey from UKDS and GESIS has been difficult, but I have managed to locate the correct variables and produce the following uncluttered tables: Young people’s trust in older people [a166]
Older people’s trust in young people [a167]
. . using the CTABLES commands: ctables /vlabels variables=x003r a166 display=none /table a166 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a166 total=yes position=after. ctables /vlabels variables=x003r a167 display=none /table a167 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a167 total=yes position=after. Can anyone suggest how I can modify the syntax to replace 100.0 in the Total row with the counts used as base Ns and Total with n = 100%? I can do it with the row% but not with the col%. This Old Dog still needs to learn some New Tricks. Thanks in advance John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop PS If anyone knows of similar questions in other surveys, especially before 2005, we’d be grateful to hear about them. |
Here is an example using employee data.sav.
All generated from the Ctables gui, but I deleted redundant syntax.
CTABLES /TABLE educ [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY jobcat /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=educ TOTAL=YES LABEL='n = 100%' . Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: John F Hall <[hidden email]> To: [hidden email] Date: 11/12/2014 01:50 PM Subject: [SPSSX-L] CTABLES for col % Sent by: "SPSSX(r) Discussion" <[hidden email]> Dominic Abrams (Professor of Social Psychology, Kent) is currently preparing a 'driver review' for the (UK) Government Office of Science on the topic of social attitudes to ageing in the UK. He has asked me for some analysis of the 1981 European Values Survey on which I worked with his grandfather, the late Dr Mark Abrams, many years ago.
Matching up variable names in three different versions of SPSS *.sav files and questionnaires from the same survey from UKDS and GESIS has been difficult, but I have managed to locate the correct variables and produce the following uncluttered tables:
Young people’s trust in older people [a166]
Older people’s trust in young people [a167]
. . using the CTABLES commands:
ctables /vlabels variables=x003r a166 display=none /table a166 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a166 total=yes position=after.
ctables /vlabels variables=x003r a167 display=none /table a167 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a167 total=yes position=after.
Can anyone suggest how I can modify the syntax to replace 100.0 in the Total row with the counts used as base Ns and Total with n = 100%? I can do it with the row% but not with the col%.
This Old Dog still needs to learn some New Tricks.
Thanks in advance
John F Hall (Mr) [Retired academic survey researcher]
Email: johnfhall@... Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop
PS If anyone knows of similar questions in other surveys, especially before 2005, we’d be grateful to hear about them.
===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (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 |
Jon and Tim sent different solutions (thanks to both): *Hennigan. ctables /table a167 [c] [totals[count,f8.0,"n= 100%"], colpct.count,f8.1,"%"] by x003r [c] /categories variables= a167 total=yes LABEL=”n=100%” position=after. *Peck. CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=x003r TOTAL=YES LABEL='n = 100%' . They both produce the same table:
My original syntax was: ctables /vlabels variables=x003r a167 display=none /table a167 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a167 total=yes position=after. . . which produces: Older people’s trust in young people [a167]
The table I want needs to look like this:
Even better would be a Total column headed All either before or after (as in Valid Percent from frequencies, but with N instead 100%.
Traditional presentation would be:
. . but most of my underlying pedagogy is based on partitioning a known distribution or statistic into its constituent parts, so my preferred layout would be:
I can produce the same table with age groups as the row variable, making comparisons between age groups visually easier, but it gets too wide to display for emails and Word. John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jon K Peck Here is an example using employee data.sav. All generated from the Ctables gui, but I deleted redundant syntax.
Matching up variable names in three different versions of SPSS *.sav files and questionnaires from the same survey from UKDS and GESIS has been difficult, but I have managed to locate the correct variables and produce the following uncluttered tables: Young people’s trust in older people [a166]
Older people’s trust in young people [a167]
. . using the CTABLES commands: ctables /vlabels variables=x003r a166 display=none /table a166 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a166 total=yes position=after. ctables /vlabels variables=x003r a167 display=none /table a167 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a167 total=yes position=after. Can anyone suggest how I can modify the syntax to replace 100.0 in the Total row with the counts used as base Ns and Total with n = 100%? I can do it with the row% but not with the col%. This Old Dog still needs to learn some New Tricks. Thanks in advance John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop PS If anyone knows of similar questions in other surveys, especially before 2005, we’d be grateful to hear about them. ===================== 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 |
Tim Which bit of your syntax displays the row total Ns? I’ve got this far with modifications, ctables /vlabels variables=x003r a167 display=none /table a167 [c] [totals [validn,f8.0,"n= 100%"], colpct.count f8.1,"%"] by x003r [c] /categories variables= x003r total=yes position=after.
. . but also need an extra row at the bottom for the base Ns. Traditional presentation would be:
. . but most of my underlying pedagogy is based on partitioning a known distribution or statistic into its constituent parts, so my preferred layout would be:
I can produce the same table with age groups as the row variable, making comparisons between age groups visually easier, but it gets too wide to display for emails and Word. Next trick will be to produce overlaid barcharts and/or line graphs. I’ve already produced a nice looking one for three age groups with: GRAPH /bar (grouped) pct by a167 by x003r2. Doing it with five age groups is a bit too cluttered, but I’ll see what I can do with line graphs. John From: Tim Hennigar [mailto:[hidden email]] No uses data from file provided with SPSS from GSS Thanks! (W) 416-947-7807 (H) 905-987-3250 ********************************* Notice: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail, do not use the information, delete this e-mail and destroy any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. Email transmissions cannot be guaranteed to be secure or error free. The sender therefore does not accept any liability for errors or omissions in the contents of this message that arise as a result of email transmissions. From: John F Hall [[hidden email]] Tim I’m about to modify your syntax for my example and would like to copy our exchange to the list. Is this table confidential? Does it need to be anonymised? John From: Tim Hennigar [[hidden email]] I don’t know what your are doing exactly but here is my example CTABLES /FORMAT EMPTY=BLANK UNIT=POINTS MINCOLWIDTH=45 MAXCOLWIDTH=45 /MRSETS COUNTDUPLICATES=NO /VLABELS VARIABLES=ALL DISPLAY=NONE /TABLE sex [C] [TOTALS[UCOUNT,' ',F6.0],COLPCT.VALIDN,' ',PCT5.1] BY base[C]+$ban1b[C]+$ban1a[C] /SLABELS POSITION=ROW VISIBLE=YES /CATEGORIES VAR=sex TOTAL=YES POSITION=AFTER LABEL="n=100%" EMPTY=EXCLUDE MISSING=EXCLUDE /TITLE CAPTION="Tim Hennigar" 'SPSS TABLES EXAMPLE' 'Primary Banner (Weighted) Run: Date-)DATE, Time-)TIME' TITLE= "(1) Respondent's Sex" " " "BASE: ALL RESPONDENTS" . (1) Respondent's Sex BASE: ALL RESPONDENTS
Tim Hennigar SPSS TABLES EXAMPLE Primary Banner (Weighted) Run: Date-11/13/2014, Time-8:00:39 AM Thanks! (W) 416-947-7807 (H) 905-987-3250 ********************************* Notice: This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail, do not use the information, delete this e-mail and destroy any copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. Email transmissions cannot be guaranteed to be secure or error free. The sender therefore does not accept any liability for errors or omissions in the contents of this message that arise as a result of email transmissions. From: SPSSX(r) Discussion [[hidden email]] On Behalf Of John F Hall Jon and Tim sent different solutions (thanks to both): *Hennigan. ctables /table a167 [c] [totals[count,f8.0,"n= 100%"], colpct.count,f8.1,"%"] by x003r [c] /categories variables= a167 total=yes LABEL=”n=100%” position=after. *Peck. CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=x003r TOTAL=YES LABEL='n = 100%' . They both produce the same table:
My original syntax was: ctables /vlabels variables=x003r a167 display=none /table a167 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a167 total=yes position=after. . . which produces: Older people’s trust in young people [a167]
The table I want needs to look like this:
Even better would be a Total column headed All either before or after (as in Valid Percent from frequencies, but with N instead 100%.
Traditional presentation would be:
. . but most of my underlying pedagogy is based on partitioning a known distribution or statistic into its constituent parts, so my preferred layout would be:
I can produce the same table with age groups as the row variable, making comparisons between age groups visually easier, but it gets too wide to display for emails and Word. John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Jon K Peck Here is an example using employee data.sav. All generated from the Ctables gui, but I deleted redundant syntax.
Matching up variable names in three different versions of SPSS *.sav files and questionnaires from the same survey from UKDS and GESIS has been difficult, but I have managed to locate the correct variables and produce the following uncluttered tables: Young people’s trust in older people [a166]
Older people’s trust in young people [a167]
. . using the CTABLES commands: ctables /vlabels variables=x003r a166 display=none /table a166 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a166 total=yes position=after. ctables /vlabels variables=x003r a167 display=none /table a167 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a167 total=yes position=after. Can anyone suggest how I can modify the syntax to replace 100.0 in the Total row with the counts used as base Ns and Total with n = 100%? I can do it with the row% but not with the col%. This Old Dog still needs to learn some New Tricks. Thanks in advance John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop PS If anyone knows of similar questions in other surveys, especially before 2005, we’d be grateful to hear about them. ===================== 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 ===================== 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 |
In reply to this post by Jon K Peck
Jon The measurement levels in EVS 1981 are haywire: they are all Scale and need to be reset to avoid error messages : var lev a165 (nom) a166 a167 x003r x003r2 (ord). exec. The syntax you sent (substituting my variables): CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL='n = 100%' . does this:
(Ns for age groups, but no total % for trust values) . . but I want an extra column headed “Total” or preferably “All” showing % for the whole sample. I’ve also tried: CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=x003r TOTAL=YES LABEL='n = 100%' .
( Total % for trust, but no Ns for age groups) In this table “n = 100%” needs changing to “All” but I can do that myself. So far I’ve got one table or the or the other, but not both. That’s what I’ve spent hours trying to do and the nearest I’ve got is: ctables /TABLE a167 [c] BY x003r [C] [colPCT.COUNT f8.1 "%" TOTALS[COUNT f8.1 "%"]] /CATEGORIES VARIABLES= x003r TOTAL=YES POSITION=AFTER LABEL="All" /CATEGORIES VARIABLES= a167 TOTAL=YES POSITION=AFTER LABEL="n = 100%". [NB: % suppressed in body of table: new row indicating statistic displayed is %]
All I need is a tweak to the syntax to yield the base for % within each agegroup (? VALIDN ?) instead of 100.0 in the bottom row, but leaving overall total N as 1128 (not 1128.0). [Hand-made table]
I’ve been going round in circles trying to get that, so far to no avail. I’m beginning to feel like the guy at the coffee machine where each choice is labelled: Coffee/no cup Cup/ no coffee Milk, sugar/ no coffee etc. This kind of table is likely to be repeated dozens of times in my tutorials, so it’s worth the effort to get it right . I’d even be prepared to create a tutorial showing how it’s done in GUI, but step-by-step with screenshots at each step. Remember I’m writing for newbies, not professional programmers. Has anyone thought of an additional facility in CROSSTABS to produce the same table(s)? cro a167 by x003r /cel col / coltot validn . [my colour coding as SPSS doesn’t do it for abbreviated syntax] John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jon K Peck Here is an example using employee data.sav. All generated from the Ctables gui, but I deleted redundant syntax.
Matching up variable names in three different versions of SPSS *.sav files and questionnaires from the same survey from UKDS and GESIS has been difficult, but I have managed to locate the correct variables and produce the following uncluttered tables: Young people’s trust in older people [a166]
Older people’s trust in young people [a167]
. . using the CTABLES commands: ctables /vlabels variables=x003r a166 display=none /table a166 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a166 total=yes position=after. ctables /vlabels variables=x003r a167 display=none /table a167 [c] by x003r [c] [colpct.count f8.1 "%" totals[count f8.0 "n= 100%"]] /categories variables= a167 total=yes position=after. Can anyone suggest how I can modify the syntax to replace 100.0 in the Total row with the counts used as base Ns and Total with n = 100%? I can do it with the row% but not with the col%. This Old Dog still needs to learn some New Tricks. Thanks in advance John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop PS If anyone knows of similar questions in other surveys, especially before 2005, we’d be grateful to hear about them. ===================== 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 |
Tim Very grateful for this. *Hennigar. COMPUTE base=1. VAR LAB base " ". VAL LAB base 1 "All". CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY base[c] + x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL='n = 100%' . Et Voila! [My post-production shading and adjustments to columns widths]
Alternatively: CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r + base [c] /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL='n = 100%' . [My post-production shading and adjustments to columns widths]
Just got to get rid of % in body cells CTABLES /TABLE a167 [COLPCT.COUNT F5.1 "%", TOTALS[COUNT F5.0 "%" ]] BY x003r + base [c] /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL="n = 100%" . [My post-production shading and adjustments to columns widths]
. . and add column header with %: been trying all afternoon without success. Any offers of a final tweak, anyone? However, a bit of serendipity following an unintentional syntax error: CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY base[c] .
Can I get N as base? Yes: CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL='n = 100%' .
This is a useful alternative to FREQUENCIES: will now spend the weekend getting N into another row at the bottom of the same column. Hang on a second . . CTABLES /TABLE a167 [COLPCT F5.1 "%", TOTALS [COUNT F5.0 ]] + base [c] /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 LABEL="n = 100%". [For some reason CTABLES stayed red, but it worked anyway.]
Eureka! Reward self with England vs Slovenia (k.o. in 29 mins) and a can or three of Old Speckled Hen when other half has gone to Eric Bibb (Blues guitar) concert in Coutances. John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop From: Tim Hennigar [mailto:[hidden email]] to get a total col - use Date: Sat, 15 Nov 2014 10:52:15 +0100 Jon The measurement levels in EVS 1981 are haywire: they are all Scale and need to be reset to avoid error messages : var lev a165 (nom) a166 a167 x003r x003r2 (ord). exec. The syntax you sent (substituting my variables): CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL='n = 100%' . does this:
(Ns for age groups, but no total % for trust values) . . but I want an extra column headed “Total” or preferably “All” showing % for the whole sample. I’ve also tried: CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=x003r TOTAL=YES LABEL='n = 100%' .
( Total % for trust, but no Ns for age groups) In this table “n = 100%” needs changing to “All” but I can do that myself. So far I’ve got one table or the or the other, but not both. That’s what I’ve spent hours trying to do and the nearest I’ve got is: ctables /TABLE a167 [c] BY x003r [C] [colPCT.COUNT f8.1 "%" TOTALS[COUNT f8.1 "%"]] /CATEGORIES VARIABLES= x003r TOTAL=YES POSITION=AFTER LABEL="All" /CATEGORIES VARIABLES= a167 TOTAL=YES POSITION=AFTER LABEL="n = 100%". [NB: % suppressed in body of table: new row indicating statistic displayed is %]
All I need is a tweak to the syntax to yield the base for % within each agegroup (? VALIDN ?) instead of 100.0 in the bottom row, but leaving overall total N as 1128 (not 1128.0). [Hand-made table]
I’ve been going round in circles trying to get that, so far to no avail. I’m beginning to feel like the guy at the coffee machine where each choice is labelled: Coffee/no cup Cup/ no coffee Milk, sugar/ no coffee etc. This kind of table is likely to be repeated dozens of times in my tutorials, so it’s worth the effort to get it right . I’d even be prepared to create a tutorial showing how it’s done in GUI, but step-by-step with screenshots at each step. Remember I’m writing for newbies, not professional programmers. Has anyone thought of an additional facility in CROSSTABS to produce the same table(s)? cro a167 by x003r /cel col / coltot validn . [my colour coding as SPSS doesn’t do it for abbreviated syntax] John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Jon K Peck Here is an example using employee data.sav. All generated from the Ctables gui, but I deleted redundant syntax.
===================== 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 |
Just to add a little more automation, you
can use OUTPUT MODIFY to color the "All" column and Totals row,
and you can set the column widths there, too. You can generate the
syntax from the Custom Tables gui in V21 or later.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: "John F Hall" <[hidden email]> To: "'Tim Hennigar'" <[hidden email]> Cc: "'Dominic Abrams'" <[hidden email]>, <[hidden email]>, "'Bruce Weaver'" <[hidden email]>, Jon K Peck/Chicago/IBM@IBMUS, "'Andy W'" <[hidden email]>, "'Jignesh Sutar'" <[hidden email]> Date: 11/15/2014 10:32 AM Subject: RE: CTABLES for col % Tim
Very grateful for this.
*Hennigar. COMPUTE base=1. VAR LAB base " ". VAL LAB base 1 "All".
CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY base[c] + x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL='n = 100%' .
Et Voila!
[My post-production shading and adjustments to columns widths]
Alternatively:
CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r + base [c] /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL='n = 100%' .
[My post-production shading and adjustments to columns widths]
Just got to get rid of % in body cells
CTABLES /TABLE a167 [COLPCT.COUNT F5.1 "%", TOTALS[COUNT F5.0 "%" ]] BY x003r + base [c] /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL="n = 100%" .
[My post-production shading and adjustments to columns widths]
. . and add column header with %: been trying all afternoon without success. Any offers of a final tweak, anyone?
However, a bit of serendipity following an unintentional syntax error:
CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY base[c] .
Can I get N as base? Yes:
CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL='n = 100%' .
This is a useful alternative to FREQUENCIES: will now spend the weekend getting N into another row at the bottom of the same column. Hang on a second . .
CTABLES /TABLE a167 [COLPCT F5.1 "%", TOTALS [COUNT F5.0 ]] + base [c] /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 LABEL="n = 100%".
[For some reason CTABLES stayed red, but it worked anyway.]
Eureka!
Reward self with England vs Slovenia (k.o. in 29 mins) and a can or three of Old Speckled Hen when other half has gone to Eric Bibb (Blues guitar) concert in Coutances.
John F Hall (Mr) [Retired academic survey researcher]
Email: johnfhall@... Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop
From: Tim Hennigar [mailto:tim.hennigar@...]
to get a total col - use Date: Sat, 15 Nov 2014 10:52:15 +0100 Jon
The measurement levels in EVS 1981 are haywire: they are all Scale and need to be reset to avoid error messages :
var lev a165 (nom) a166 a167 x003r x003r2 (ord). exec.
The syntax you sent (substituting my variables):
CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=a167 TOTAL=YES LABEL='n = 100%' .
does this:
(Ns for age groups, but no total % for trust values)
. . but I want an extra column headed “Total” or preferably “All” showing % for the whole sample.
I’ve also tried:
CTABLES /TABLE a167 [COLPCT.COUNT PCT40.1, TOTALS[COUNT F40.0]] BY x003r /SLABELS POSITION=ROW VISIBLE=NO /CATEGORIES VARIABLES=x003r TOTAL=YES LABEL='n = 100%' .
( Total % for trust, but no Ns for age groups)
In this table “n = 100%” needs changing to “All” but I can do that myself.
So far I’ve got one table or the or the other, but not both.
That’s what I’ve spent hours trying to do and the nearest I’ve got is:
ctables /TABLE a167 [c] BY x003r [C] [colPCT.COUNT f8.1 "%" TOTALS[COUNT f8.1 "%"]] /CATEGORIES VARIABLES= x003r TOTAL=YES POSITION=AFTER LABEL="All" /CATEGORIES VARIABLES= a167 TOTAL=YES POSITION=AFTER LABEL="n = 100%".
[NB: % suppressed in body of table: new row indicating statistic displayed is %]
All I need is a tweak to the syntax to yield the base for % within each agegroup (? VALIDN ?) instead of 100.0 in the bottom row, but leaving overall total N as 1128 (not 1128.0).
[Hand-made table]
I’ve been going round in circles trying to get that, so far to no avail. I’m beginning to feel like the guy at the coffee machine where each choice is labelled:
Coffee/no cup Cup/ no coffee Milk, sugar/ no coffee etc.
This kind of table is likely to be repeated dozens of times in my tutorials, so it’s worth the effort to get it right . I’d even be prepared to create a tutorial showing how it’s done in GUI, but step-by-step with screenshots at each step. Remember I’m writing for newbies, not professional programmers.
Has anyone thought of an additional facility in CROSSTABS to produce the same table(s)?
cro a167 by x003r /cel col / coltot validn .
[my colour coding as SPSS doesn’t do it for abbreviated syntax]
John F Hall (Mr) [Retired academic survey researcher]
Email: johnfhall@... Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop
From: SPSSX(r) Discussion [[hidden email]]
On Behalf Of Jon K Peck
Here is an example using employee data.sav.
All generated from the Ctables gui, but I deleted redundant syntax.
===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (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 |
Free forum by Nabble | Edit this page |