I’m struggling to get the kind of tables I want from CTABLES. I have a set of (self-reported) physical symptoms and want a summary table which displays mean satisfaction (on a 0 – 10 scale) with own health for each level of each symptom. I can do this separately for each symptom using MEANS, but would prefer a summary table to include them all. Working from the CSR, I’ve got as far as producing a summary table for the symptoms to display COUNT only, ROWPCT only or both (as below): CTABLES /TABLE (var422 + var423 + var424 + var425 + var426 + var427 + var428 + var429 + var430 + var431 + var432 + var433 + var434 + var435 + var436 ) [COUNT ROWPCT] /CLABELS ROWLABELS=OPPOSITE.
There are no examples in the CSR for displaying means, which should be something like the example below, displaying mean satisfaction with own health for each level of each symptom. A simple table like this is sufficient to demonstrate very steep gradients in health satisfaction.
I should also like options to add a column for overall mean at left or right, and to insert base n for each mean. [Jon, David, Jignesh: Just thought I’d ruin your Sunday!] 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 |
Administrator
|
Here is a way to do it with 'old skool' TABLES. I generally don't mess with CTABLES unless there is a good reason. Syntax is way too obtuse in my not so humble opinion (IMNSHO).
Note the data require restructuring (often a key element in such requests). ------ /* sim */. MATRIX. SAVE TRUNC(UNIFORM(1000,10)*6+1) / OUTFILE * / VARIABLES x01 TO x10 . END MATRIX. VARIABLE LEVEL x01 TO x10 (ORDINAL). COMPUTE overall=TRUNC(RV.UNIFORM(1,10)). VARIABLE LEVEL overall(SCALE). VARSTOCASES /MAKE x FROM x01 TO x10 /INDEX=varname(x). TABLES OBSERVATION overall / TABLES=overall > varname BY x .
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
David Thanks for that, but to me it’s even more obtuse than CTABLES. It looks as if my tables didn’t display properly, but here’s a basic one for var438 by one or two symptoms using MEANS: means var438 by var422 to var424.
I want to get a single summary table for the means into a table like this:
John -----Original Message----- Here is a way to do it with 'old skool' TABLES. I generally don't mess with CTABLES unless there is a good reason. Syntax is way too obtuse in my not so humble opinion (IMNSHO). Note the data require restructuring (often a key element in such requests). ------ /* sim */. MATRIX. SAVE TRUNC(UNIFORM(1000,10)*6+1) / OUTFILE * / VARIABLES x01 TO x10 . END MATRIX. VARIABLE LEVEL x01 TO x10 (ORDINAL). COMPUTE overall=TRUNC(RV.UNIFORM(1,10)). VARIABLE LEVEL overall(SCALE). VARSTOCASES /MAKE x FROM x01 TO x10 /INDEX=varname(x). TABLES OBSERVATION overall / TABLES=overall > varname BY x . John F Hall wrote > I'm struggling to get the kind of tables I want from CTABLES. > > I have a set of (self-reported) physical symptoms and want a summary > table which displays mean satisfaction (on a 0 - 10 scale) with own > health for each level of each symptom. I can do this separately for > each symptom using MEANS, but would prefer a summary table to include > them all. > > Working from the CSR, I've got as far as producing a summary table for > the symptoms to display COUNT only, ROWPCT only or both (as below): > > CTABLES /TABLE > (var422 + var423 + var424 + var425 + var426 + var427 + var428 + var429 > + var430 + var431 + var432 + var433 + var434 + var435 + var436 ) > [COUNT ROWPCT] > /CLABELS ROWLABELS=OPPOSITE. > > > > > Not at all > A little > Quite a lot > A great deal > > Count > Row N % > Count > Row N % > Count > Row N % > Count > Row N % > > Q.E4a Cold or flu > 518 > 56.2% > 287 > 31.1% > 79 > 8.6% > 38 > 4.1% > > Q.E4b Dizziness > 762 > 82.1% > 113 > 12.2% > 38 > 4.1% > 15 > 1.6% > > Q.E4c General aches and pains > 409 > 44.3% > 353 > 38.2% > 124 > 13.4% > 37 > 4.0% > > Q.E4d Hands sweating > 796 > 85.9% > 86 > 9.3% > 34 > 3.7% > 11 > 1.2% > > Q.E4e Headaches > 493 > 53.1% > 318 > 34.2% > 101 > 10.9% > 17 > 1.8% > > Q.E4f Muscle twitches or trembling > 758 > 81.7% > 114 > 12.3% > 42 > 4.5% > 14 > 1.5% > > Q.E4g Nervousness or tenseness > 523 > 56.3% > 275 > 29.6% > 91 > 9.8% > 40 > 4.3% > > Q.E4h Rapid heart beat > 785 > 84.7% > 103 > 11.1% > 31 > 3.3% > 8 > 0.9% > > Q.E4j Shortness of breath > 717 > 77.2% > 141 > 15.2% > 41 > 4.4% > 30 > 3.2% > > Q.E4k Skin rashes > 829 > 89.4% > 72 > 7.8% > 14 > 1.5% > 12 > 1.3% > > Q.E4l Upset stomach > 658 > 70.8% > 207 > 22.3% > 53 > 5.7% > 11 > 1.2% > > Q.E4m Feeling generally run down > 512 > 55.1% > 303 > 32.6% > 80 > 8.6% > 35 > 3.8% > > Q.E4n Female complaints > 473 > 87.6% > 49 > 9.1% > 12 > 2.2% > 6 > 1.1% > > Q.E5a Trouble getting to sleep > 602 > 64.7% > 169 > 18.2% > 115 > 12.4% > 45 > 4.8% > > Q.E5b Trouble staying asleep > 697 > 74.9% > 123 > 13.2% > 75 > 8.1% > 35 > 3.8% > > There are no examples in the CSR for displaying means, which should be > something like the example below, displaying mean satisfaction with > own health for each level of each symptom. A simple table like this > is sufficient to demonstrate very steep gradients in health satisfaction. > > > > Not at all > A little > Quite a lot > A great deal > > > Mean > > Mean > > Mean > > Mean > > Q.E4a Cold or flu > > > > > > > > > Q.E4b Dizziness > > > > > > > > > Q.E4c General aches and pains > > > > > > > > > Q.E4d Hands sweating > > > > > > > > > Q.E4e Headaches > > > > > > > > > Q.E4f Muscle twitches or trembling > > > > > > > > > Q.E4g Nervousness or tenseness > > > > > > > > > Q.E4h Rapid heart beat > > > > > > > > > Q.E4j Shortness of breath > > > > > > > > > Q.E4k Skin rashes > > > > > > > > > Q.E4l Upset stomach > > > > > > > > > Q.E4m Feeling generally run down > > > > > > > > > Q.E4n Female complaints > > > > > > > > > Q.E5a Trouble getting to sleep > > > > > > > > > Q.E5b Trouble staying asleep > > > > > > > > > > I should also like options to add a column for overall mean at left or > right, and to insert base n for each mean. > > [Jon, David, Jignesh: Just thought I'd ruin your Sunday!] > > Thanks in advance > > John F Hall (Mr) > [Retired academic survey researcher] > > Email: <mailto: > johnfhall@ > > > johnfhall@ > > Website: <http://www.surveyresearch.weebly.com/> > www.surveyresearch.weebly.com > SPSS start page: > <http://surveyresearch.weebly.com/1-survey-analysis-workshop.html&g > t; www.surveyresearch.weebly.com/1-survey-analysis-workshop > > > > > > ===================== > To manage your subscription to SPSSX-L, send a message to > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/CTABLES-on-Sunday-tp5728603p5728604.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 |
This isn't a solution to what you are trying to achieve but to just demonstrate what it is exactly that you are trying to do with CTABLES and perhaps justification for logging a Enhancement Request (good luck navigating the IBM website!). "Table 1" is the structure of the table you wish to acheive, which works great with CTABLES ROWLABELS=OPPOSITE but however, you'd like to produce the means score for each cell in this table of another variable (OSat). So "Table 2" below tries to do this in the CTABLE syntax convention but it fails. "Table 3" shows how to do this but it can only be achieved in the "long" format of the table. I think the syntax for "Table 2" could potentially be a valid use for this type of operation and perhaps worth a ER log. But otherwise, Davids' solution is a easy enough workaround. **************************************. set seed = 10. input program. loop #i = 1 to 500. compute case = #i. end case. end loop. end file. end input program. dataset name sim. vector Likert(9, F1.0). do repeat Likert = Likert1 to Likert9. compute Likert = TRUNC(RV.UNIFORM(1,5)). end repeat. compute OSat=rnd(rv.uniform(0,10)). value labels Likert1 to Likert9 1 'Not at all' 2 'A little' 3 'Quite a lot' 4 'A great deal'.  **************************************. /* Neat summary table using ROWLABELS=OPPOSITE */. ctables  /table (Likert1+Likert2+Likert3+Likert4+Likert5+Likert6+Likert7+Likert8+Likert9)[c]  /clabels rowlabels=opposite /titles title="Table 1". /* However fails if using nested scale variable */. ctables  /table (Likert1+Likert2+Likert3+Likert4+Likert5+Likert6+Likert7+Likert8+Likert9)[c]>OSat[s][mean]  /clabels rowlabels=opposite /titles title="Table 2". /* Nesting works only if in original table structure format */. ctables  /table (Likert1+Likert2+Likert3+Likert4+Likert5+Likert6+Likert7+Likert8+Likert9)[c]>OSat[s][mean]  /titles title="Table 3". On 8 February 2015 at 17:35, John F Hall <[hidden email]> wrote:
|
Jignesh, David Thanks for your suggestions, which I’ve now tried. Jignesh is quite right, only David’s solution does what I want: if I can work out his syntax I’ll amend it to use on my own data. [One hour 25 minutes later] My first shot with only three items: VARSTOCASES /MAKE x FROM var422 to var424 /INDEX=varname(x). compute y = mean(var438). TABLES OBSERVATION y / TABLES=y > varname BY x .  worked fine (apart from the upper label):
but when I editied the command to extend the number of variables I kept getting error messages until I realised that the vars I wanted had disappeared from Variable View to Data View. I finally came up with: VARSTOCASES /MAKE x FROM var422 to var436 /INDEX=varname(x). compute y = mean(var438). TABLES OBSERVATION y / TABLES=y > varname BY x .
Nearly there. Just needed to eliminate men from var434 codes 7 and 8 (. . any female complaints?) change the upper label (in Pivot table) et Voilà ! Be nice if variable labels were displayed instead of names.
Final attempt: (overcoming logical issue of label, and just guessing for MISSING VALUES) VARSTOCASES Â Â Â /MAKE x "Mean satisfaction (0 - 10) with own health" Â Â Â Â Â Â Â Â Â Â Â Â Â Â FROM var422 to var433 var435 var436 Â Â Â /INDEX=varname(x). compute y = mean(var438). missing values x (7,8,9). TABLES OBSERVATION y / TABLES=y > varname BY x .
Changing settings to Labels makes no difference, and really tedious to do it all by hand, so copied column from existing DISPLAY LABELS table to the Pivot:
Just what the doctor ordered. Would this work copying labels from the Data Editor instead? Nice learning experience making sure the original *.sav file is not overwritten, at least until I’ve tried CASESTOVARS As Jignesh suggests, it’s worth adding this table format to the wish list for CTABLES. John 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 Jignesh Sutar This isn't a solution to what you are trying to achieve but to just demonstrate what it is exactly that you are trying to do with CTABLES and perhaps justification for logging a Enhancement Request (good luck navigating the IBM website!). "Table 1" is the structure of the table you wish to acheive, which works great with CTABLES ROWLABELS=OPPOSITE but however, you'd like to produce the means score for each cell in this table of another variable (OSat). So "Table 2" below tries to do this in the CTABLE syntax convention but it fails. "Table 3" shows how to do this but it can only be achieved in the "long" format of the table. I think the syntax for "Table 2" could potentially be a valid use for this type of operation and perhaps worth a ER log. But otherwise, Davids' solution is a easy enough workaround. **************************************. /* However fails if using nested scale variable */. /* Nesting works only if in original table structure format */. On 8 February 2015 at 17:35, John F Hall <[hidden email]> wrote: David Thanks for that, but to me it’s even more obtuse than CTABLES. It looks as if my tables didn’t display properly, but here’s a basic one for var438 by one or two symptoms using MEANS: means var438 by var422 to var424.
I want to get a single summary table for the means into a table like this:
John -----Original Message----- Here is a way to do it with 'old skool' TABLES. I generally don't mess with CTABLES unless there is a good reason. Syntax is way too obtuse in my not so humble opinion (IMNSHO). Note the data require restructuring (often a key element in such requests). ------ /* sim */. MATRIX. SAVE TRUNC(UNIFORM(1000,10)*6+1) / OUTFILE * / VARIABLES x01 TO x10 . END MATRIX. VARIABLE LEVEL x01 TO x10 (ORDINAL). COMPUTE overall=TRUNC(RV.UNIFORM(1,10)). VARIABLE LEVEL overall(SCALE). VARSTOCASES /MAKE x FROM x01 TO x10 /INDEX=varname(x). TABLES OBSERVATION overall / TABLES=overall > varname BY x . John F Hall wrote > I'm struggling to get the kind of tables I want from CTABLES. > > I have a set of (self-reported) physical symptoms and want a summary > table which displays mean satisfaction (on a 0 - 10 scale) with own > health for each level of each symptom. I can do this separately for > each symptom using MEANS, but would prefer a summary table to include > them all. > > Working from the CSR, I've got as far as producing a summary table for > the symptoms to display COUNT only, ROWPCT only or both (as below): > > CTABLES /TABLE > (var422 + var423 + var424 + var425 + var426 + var427 + var428 + var429 > + var430 + var431 + var432 + var433 + var434 + var435 + var436 ) > [COUNT ROWPCT] > /CLABELS ROWLABELS=OPPOSITE. > > > > > Not at all > A little > Quite a lot > A great deal > > Count > Row N % > Count > Row N % > Count > Row N % > Count > Row N % > > Q.E4a Cold or flu > 518 > 56.2% > 287 > 31.1% > 79 > 8.6% > 38 > 4.1% > > Q.E4b Dizziness > 762 > 82.1% > 113 > 12.2% > 38 > 4.1% > 15 > 1.6% > > Q.E4c General aches and pains > 409 > 44.3% > 353 > 38.2% > 124 > 13.4% > 37 > 4.0% > > Q.E4d Hands sweating > 796 > 85.9% > 86 > 9.3% > 34 > 3.7% > 11 > 1.2% > > Q.E4e Headaches > 493 > 53.1% > 318 > 34.2% > 101 > 10.9% > 17 > 1.8% > > Q.E4f Muscle twitches or trembling > 758 > 81.7% > 114 > 12.3% > 42 > 4.5% > 14 > 1.5% > > Q.E4g Nervousness or tenseness > 523 > 56.3% > 275 > 29.6% > 91 > 9.8% > 40 > 4.3% > > Q.E4h Rapid heart beat > 785 > 84.7% > 103 > 11.1% > 31 > 3.3% > 8 > 0.9% > > Q.E4j Shortness of breath > 717 > 77.2% > 141 > 15.2% > 41 > 4.4% > 30 > 3.2% > > Q.E4k Skin rashes > 829 > 89.4% > 72 > 7.8% > 14 > 1.5% > 12 > 1.3% > > Q.E4l Upset stomach > 658 > 70.8% > 207 > 22.3% > 53 > 5.7% > 11 > 1.2% > > Q.E4m Feeling generally run down > 512 > 55.1% > 303 > 32.6% > 80 > 8.6% > 35 > 3.8% > > Q.E4n Female complaints > 473 > 87.6% > 49 > 9.1% > 12 > 2.2% > 6 > 1.1% > > Q.E5a Trouble getting to sleep > 602 > 64.7% > 169 > 18.2% > 115 > 12.4% > 45 > 4.8% > > Q.E5b Trouble staying asleep > 697 > 74.9% > 123 > 13.2% > 75 > 8.1% > 35 > 3.8% > > There are no examples in the CSR for displaying means, which should be > something like the example below, displaying mean satisfaction with > own health for each level of each symptom. A simple table like this > is sufficient to demonstrate very steep gradients in health satisfaction. > > > > Not at all > A little > Quite a lot > A great deal > > > Mean > > Mean > > Mean > > Mean > > Q.E4a Cold or flu > > > > > > > > > Q.E4b Dizziness > > > > > > > > > Q.E4c General aches and pains > > > > > > > > > Q.E4d Hands sweating > > > > > > > > > Q.E4e Headaches > > > > > > > > > Q.E4f Muscle twitches or trembling > > > > > > > > > Q.E4g Nervousness or tenseness > > > > > > > > > Q.E4h Rapid heart beat > > > > > > > > > Q.E4j Shortness of breath > > > > > > > > > Q.E4k Skin rashes > > > > > > > > > Q.E4l Upset stomach > > > > > > > > > Q.E4m Feeling generally run down > > > > > > > > > Q.E4n Female complaints > > > > > > > > > Q.E5a Trouble getting to sleep > > > > > > > > > Q.E5b Trouble staying asleep > > > > > > > > > > I should also like options to add a column for overall mean at left or > right, and to insert base n for each mean. > > [Jon, David, Jignesh: Just thought I'd ruin your Sunday!] > > Thanks in advance > > John F Hall (Mr) > [Retired academic survey researcher] > > Email: <mailto: > johnfhall@ > > > johnfhall@ > > Website: <http://www.surveyresearch.weebly.com/> > www.surveyresearch.weebly.com > SPSS start page: > <http://surveyresearch.weebly.com/1-survey-analysis-workshop.html&g > t; www.surveyresearch.weebly.com/1-survey-analysis-workshop > > > > > > ===================== > To manage your subscription to SPSSX-L, send a message to > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/CTABLES-on-Sunday-tp5728603p5728604.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 ===================== 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 |