Dear all,
Is it possible to have a syntax for the following table: The categories/labels for the variables A, C and D are the same (like A1,A2,A3). I only managed to make a syntax for the following table: Which is: !ctable3 b/a. DEFINE !ctable3(row=!CHAREND('/') /col=!CMDEND) CTABLES /FORMAT MINCOLWIDTH=92 MAXCOLWIDTH=92 UNITS=POINTS /VLABELS VARIABLES=!row DISPLAY=NONE /VLABELS VARIABLES=!col DISPLAY=LABEL /TABLE !HEAD(!row) !DO !v !IN (!TAIL(!row)) + !v !DOEND BY (!HEAD(!col) !DO !v !IN (!TAIL(!col)) + !v !DOEND ) [ROWPCT.COUNT '' F5.1] /TITLE CORNER='%' /CATEGORIES VARIABLES=!col ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=NO /CATEGORIES VARIABLES= !row [SUBTOTAL='Total', 0, 1, 2, OTHERNM] EMPTY=EXCLUDE POSITION=BEFORE. !ENDDEFINE. Best regards, Katja. |
Not entirely sure but I think that you need to add an additional layer to your table.
Add an extra 'BY' section to your syntax to add a layer. BY (!HEAD(!col) !DO !v !IN (!TAIL(!col)) + !v !DOEND ) [ROWPCT.COUNT '' F5.1] BY A[C] + C[C] + D[C] Hope this helps "Lo there do I see my father. Lo there do I see my mother and my sisters and my brothers. Lo there do I see the line of my people, back to the beginning. Lo, they do call to me, they bid me take my place among them, in the Halls of Valhalla, where the brave may live...forever." |
Administrator
|
This post was updated on .
In reply to this post by vki23
Always best to figure out the basic syntax before trying to muck around with MACRO.
Also when talking about CTABLES you need to describe the variable levels. When trying to get help with macro you need to show how you are calling the macro. In your case you really don't need to bother with a macro at all. DATA LIST FREE / A B C. BEGIN DATA 1 1 1 1 1 2 1 2 1 1 2 2 2 1 1 2 1 2 2 2 1 2 2 2 2 2 2 END DATA. VARIABLE LEVEL A B C (NOMINAL). VALUE LABELS A 1 'a 1' 2 'a2' / B 1 'b1' 2 'b2' / C 1 'c1' 2 'c2'. SET TNumbers Labels. CTABLES /TABLE A > B BY C . <Edit> Nixed badly formatted table: Posted JPG
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?" |
In reply to this post by vki23
Katya Is this the sort of table you want? If so I need to look for the syntax for it (or something logically similar). John F Hall (Mr) Email: [hidden email] Website: www.surveyresearch.weebly.com
-----Original Message----- Dear all, Is it possible to have a syntax for the following table: <http://spssx-discussion.1045642.n5.nabble.com/file/n5716535/table1.jpg> The categories/labels for the variables A, C and D are the same (like A1,A2,A3). I only managed to make a syntax for the following table: <http://spssx-discussion.1045642.n5.nabble.com/file/n5716535/table2.jpg> Which is: !ctable3 b/a. DEFINE !ctable3(row=!CHAREND('/') /col=!CMDEND) CTABLES /FORMAT MINCOLWIDTH=92 MAXCOLWIDTH=92 UNITS=POINTS /VLABELS VARIABLES=!row DISPLAY=NONE /VLABELS VARIABLES=!col DISPLAY=LABEL /TABLE !HEAD(!row) !DO !v !IN (!TAIL(!row)) + !v !DOEND BY (!HEAD(!col) !DO !v !IN (!TAIL(!col)) + !v !DOEND ) [ROWPCT.COUNT '' F5.1] /TITLE CORNER='%' /CATEGORIES VARIABLES=!col ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=NO /CATEGORIES VARIABLES= !row [SUBTOTAL='Total', 0, 1, 2, OTHERNM] EMPTY=EXCLUDE POSITION=BEFORE. !ENDDEFINE. Best regards, Katja. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Syntax-for-a-Complex-CTABLE-tp5716535.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 |
Administrator
|
In reply to this post by vki23
Basically you need to
1. Read up on the CTABLES syntax (Drill into your brain the difference between > and BY also see +). 2. Mess around in the GUI for Custom TABLES (It has a pretty decent design IMNSHO). 3. Paste the results of various GUI mucking . 4. Nuke all the extraneous default crap the GUI generates. 5. Generalize the edited GUI splatter to extend the nesting (>), layering (BY) and concatenation (+) logic. 6. *THEN AND ONLY THEN fiddle with MACRO. You have done these steps in reverse and need to go back to the basic CTABLES algebra. ---
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?" |
In reply to this post by vki23
Katya
Here's the syntax that produced the table: CTABLES /TABLE sex [c] > age2 [c] > partnered [c] BY healthgrp [c] > satisgrp [c][ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= sex partnered age2 satisgrp TOTAL=YES POSITION=AFTER . John F Hall (Mr) Email: <mailto:[hidden email]> [hidden email] Website: <http://surveyresearch.weebly.com/> www.surveyresearch.weebly.com From: John F Hall [mailto:[hidden email]] Sent: 30 November 2012 17:54 To: 'vki23'; [hidden email] Subject: RE: Syntax for a Complex CTABLE Katya Is this the sort of table you want? If so I need to look for the syntax for it (or something logically similar). John F Hall (Mr) Email: <mailto:[hidden email]> [hidden email] Website: <http://surveyresearch.weebly.com/> www.surveyresearch.weebly.com Self-reported health Poor Good Grouped life satisfaction Grouped life satisfaction Low 0-4 Medium5 -8 High 9-10 Total Low 0-4 Medium5 -8 High 9-10 Total Row N % Row N % Row N % Count Row N % Row N % Row N % Count Sex Male Age in two groups Under 50 R has partner? Partner' 14.5% 73.2% 12.3% 2476 3.2% 71.5% 25.3% 16158 No partner 29.3% 64.6% 6.1% 2430 6.1% 75.4% 18.5% 9565 Total 21.9% 68.9% 9.2% 4906 4.3% 72.9% 22.8% 25723 50 and over R has partner? Partner' 9.0% 69.6% 21.4% 8298 2.2% 62.3% 35.6% 18332 No partner 20.3% 65.2% 14.5% 5274 5.6% 68.9% 25.5% 6212 Total 13.4% 67.9% 18.7% 13572 3.0% 63.9% 33.0% 24544 Total R has partner? Partner' 10.3% 70.4% 19.3% 10774 2.7% 66.6% 30.8% 34490 No partner 23.2% 65.0% 11.8% 7704 5.9% 72.8% 21.2% 15777 Total 15.7% 68.2% 16.2% 18478 3.7% 68.5% 27.8% 50267 Female Age in two groups Under 50 R has partner? Partner' 13.1% 69.5% 17.4% 3969 2.5% 66.1% 31.4% 22642 No partner 24.9% 65.7% 9.4% 3876 6.0% 72.9% 21.2% 13528 Total 18.9% 67.6% 13.5% 7845 3.8% 68.6% 27.6% 36170 50 and over R has partner? Partner' 8.8% 66.5% 24.7% 7631 2.2% 57.8% 39.9% 17830 No partner 15.7% 67.0% 17.3% 7931 4.7% 65.5% 29.7% 10591 Total 12.3% 66.8% 20.9% 15562 3.2% 60.7% 36.1% 28421 Total R has partner? Partner' 10.3% 67.5% 22.2% 11600 2.4% 62.5% 35.2% 40472 No partner 18.7% 66.6% 14.7% 11807 5.4% 69.6% 24.9% 24119 Total 14.5% 67.0% 18.4% 23407 3.5% 65.1% 31.4% 64591 Total Age in two groups Under 50 R has partner? Partner' 13.6% 70.9% 15.4% 6445 2.8% 68.3% 28.9% 38800 No partner 26.6% 65.2% 8.2% 6306 6.0% 73.9% 20.1% 23093 Total 20.0% 68.1% 11.8% 12751 4.0% 70.4% 25.6% 61893 50 and over R has partner? Partner' 8.9% 68.1% 23.0% 15929 2.2% 60.1% 37.7% 36162 No partner 17.5% 66.3% 16.2% 13205 5.1% 66.8% 28.2% 16803 Total 12.8% 67.3% 19.9% 29134 3.1% 62.2% 34.7% 52965 Total R has partner? Partner' 10.3% 68.9% 20.8% 22374 2.5% 64.4% 33.1% 74962 No partner 20.5% 66.0% 13.6% 19511 5.6% 70.9% 23.5% 39896 Total 15.0% 67.5% 17.4% 41885 3.6% 66.6% 29.8% 114858 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of vki23 Sent: 30 November 2012 11:16 To: [hidden email] Subject: Syntax for a Complex CTABLE Dear all, Is it possible to have a syntax for the following table: < <http://spssx-discussion.1045642.n5.nabble.com/file/n5716535/table1.jpg> http://spssx-discussion.1045642.n5.nabble.com/file/n5716535/table1.jpg> The categories/labels for the variables A, C and D are the same (like A1,A2,A3). I only managed to make a syntax for the following table: < <http://spssx-discussion.1045642.n5.nabble.com/file/n5716535/table2.jpg> http://spssx-discussion.1045642.n5.nabble.com/file/n5716535/table2.jpg> Which is: !ctable3 b/a. DEFINE !ctable3(row=!CHAREND('/') /col=!CMDEND) CTABLES /FORMAT MINCOLWIDTH=92 MAXCOLWIDTH=92 UNITS=POINTS /VLABELS VARIABLES=!row DISPLAY=NONE /VLABELS VARIABLES=!col DISPLAY=LABEL /TABLE !HEAD(!row) !DO !v !IN (!TAIL(!row)) + !v !DOEND BY (!HEAD(!col) !DO !v !IN (!TAIL(!col)) + !v !DOEND ) [ROWPCT.COUNT '' F5.1] /TITLE CORNER='%' /CATEGORIES VARIABLES=!col ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=NO /CATEGORIES VARIABLES= !row [SUBTOTAL='Total', 0, 1, 2, OTHERNM] EMPTY=EXCLUDE POSITION=BEFORE. !ENDDEFINE. Best regards, Katja. -- View this message in context: <http://spssx-discussion.1045642.n5.nabble.com/Syntax-for-a-Complex-CTABLE-t p5716535.html> http://spssx-discussion.1045642.n5.nabble.com/Syntax-for-a-Complex-CTABLE-tp 5716535.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to <mailto:[hidden email]> [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 |