CTABLES Problem

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

CTABLES Problem

Peter Cuttance
Can anyone tell me why the syntax below is producing the table for only one of the values of SUBJECTID?

I am using BY BY SUBJECTID in lieu of SPLIT FILE BY SUBJECTID which is not supported.

CTABLES
  /VLABELS VARIABLES=R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1
    DISPLAY=LABEL
  /TABLE (R1_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R2_1 [COUNT F40.0,  ROWPCT.COUNT PCT40.0] 
  + R3_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R4_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R5_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R6_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R7_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R8_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R9_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R10_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R11_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R12_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R13_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R14_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R15_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R17_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R18_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R19_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R20_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 
  + R21_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]) BY BY SUBJECTID
  /SLABELS POSITION=ROW VISIBLE=YES
  /CLABELS ROWLABELS=OPPOSITE
  /CATEGORIES VARIABLES=SUBJECTID R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1 ORDER=A KEY=LABEL MISSING=EXCLUDE EMPTY=EXCLUDE.

Prof Peter Cuttance
Director
Research Australia Development and Innovation Institute (radii.org)
Ph.    +613 9534 2934
Mob. +61 428 990 904
Fax.   +613 8640 0741
Suite 71
197 Canterbury Road
St Kilda West
Victoria AUSTRALIA 3182




Reply | Threaded
Open this post in threaded view
|

Re: CTABLES Problem

Maguin, Eugene
Peter,

If you haven't already received useful replies, would you please say what
you are wanting the table to look like. I have used ctables only a few times
so there is a lot I don't know, but in looking at the syntax reference (v18,
p. 490) the BY BY specification creates layers. Could it be that you have
what you want but don't realize it?

Gene Maguin


>>Can anyone tell me why the syntax below is producing the table for only
one of the values of SUBJECTID?

I am using BY BY SUBJECTID in lieu of SPLIT FILE BY SUBJECTID which is not
supported.

CTABLES
  /VLABELS VARIABLES=R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1
R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1
    DISPLAY=LABEL
  /TABLE (R1_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R2_1 [COUNT F40.0,  ROWPCT.COUNT PCT40.0]
  + R3_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R4_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R5_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R6_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R7_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R8_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R9_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R10_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R11_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R12_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R13_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R14_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R15_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R17_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R18_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R19_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R20_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R21_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]) BY BY SUBJECTID
  /SLABELS POSITION=ROW VISIBLE=YES
  /CLABELS ROWLABELS=OPPOSITE
  /CATEGORIES VARIABLES=SUBJECTID R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1
R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1
ORDER=A KEY=LABEL MISSING=EXCLUDE EMPTY=EXCLUDE.

Prof Peter Cuttance
Director
Research Australia Development and Innovation Institute (radii.org)
Ph.    +613 9534 2934
Mob. +61 428 990 904
Fax.   +613 8640 0741
Suite 71
197 Canterbury Road
St Kilda West
Victoria AUSTRALIA 3182

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

FW: CTABLES Problem

Dennis Deck
In reply to this post by Peter Cuttance

Sounds like you really want one table at a time then

I would use something like:

 

TEMPORARY .

SELECT IF (SubjectID= ) .

(table syntax here)

 

Or use FILTER rather then the SELECT IF

 

You can use DO REPEAT logic if you have many tables to generate:

Or can embed the CTABLES command in a macro

 

DO REPEAT s =  subject1 subject2  . . .  .

+  TEMPORARY .

+ SELECT IF (SubjectID=s) .

+  (table command here)

END REPEAT .

 

Note that SELECT IF and FILTER do not require data to be presorted as SPLIT FILES does.

I rarely use SPLIT FILES personally as my break vars are often not usually mutually exclusive

 

Dennis


From: Peter Cuttance [mailto:[hidden email]]
Sent: Thursday, January 28, 2010 3:44 AM
To: Dennis Deck
Subject: Re: CTABLES Problem

 

Hi Dennis

 

SUBJECTID is the ID for the subject the student is studying — each student has responded to a standard survey for each subject they have studied.  

 

Dropping BY BY and replacing it with BY simply results in a table that is N tables wide (where N is the number of separate SUBJECTID's.

 

I want a separate set of table results for the survey for each SUBJECTID — nornally this would be achieved by SPLIT FILE BY SUBJECTID, but this is not supported in CTABLES.

 

Any suggestions would be welcome.

 

Regards

Peter

 

Research Australia Development and Innovation Institute (radii.org)

Ph.    +613 9534 2934

Mob. +61 428 990 904

Fax.   +613 8640 0741

Suite 71

197 Canterbury Road

St Kilda West

Victoria AUSTRALIA 3182

 




 

On 28/01/2010, at 4:59 PM, Dennis Deck wrote:

 

Not sure why you are trying “BY BY” — a single “BY” is the proper syntax.

 

Perhaps you have a good reason to break the summary by SUBJECTID but it seems suspect.

Do you have more than one case per subject?  And why would you average by subject anyway?

I would expect a variable like Group or StudyCondition or Time . . ..

 

A simple command for checking results, of course, would be:

 

CROSSTABS

   Tables=  R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1

                      R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1 by Group

  /Cells= Count  Row  .

 

 

Dennis Deck

RMC Research

 


From: Peter Cuttance [[hidden email]] 
Sent: Wednesday, January 27, 2010 12:48 PM
Subject: CTABLES Problem

 

Can anyone tell me why the syntax below is producing the table for only one of the values of SUBJECTID?

 

I am using BY BY SUBJECTID in lieu of SPLIT FILE BY SUBJECTID which is not supported.

 

CTABLES

  /VLABELS VARIABLES=R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1

    DISPLAY=LABEL

  /TABLE (R1_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R2_1 [COUNT F40.0,  ROWPCT.COUNT PCT40.0] 

  + R3_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R4_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R5_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R6_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R7_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R8_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R9_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R10_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R11_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R12_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R13_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R14_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R15_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R17_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R18_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R19_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R20_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R21_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]) BY BY SUBJECTID

  /SLABELS POSITION=ROW VISIBLE=YES

  /CLABELS ROWLABELS=OPPOSITE

  /CATEGORIES VARIABLES=SUBJECTID R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1 ORDER=A KEY=LABEL MISSING=EXCLUDE EMPTY=EXCLUDE.

 

 

Reply | Threaded
Open this post in threaded view
|

Re: CTABLES Problem

Dennis Deck
In reply to this post by Peter Cuttance

If you have a list of the subjects (SUBJECTID) then simply copy that into the DO REPEAT logic.

DO REPEAT s =  subject1 subject2  . . .  .

Takes all of 2 minutes

 

You might be able to get CTABLES to place the next subject below rather than to the right.

One thought was to add a dummy variable to force CTABLES to put the next subject below rather to the right

(not sure if that will work but easy to try)

COMPUTE Dummy = 1 .

CTABLES  . . . 

 ..   BY Dummy BY SubjectID .

 

Dennis


From: Peter Cuttance [mailto:[hidden email]]
Sent: Thursday, January 28, 2010 11:08 AM
To: Dennis Deck
Subject: Re: CTABLES Problem

 

Hi Dennis

 

That would work OK — but, there are 300+ tables, so I am looking for something less laborious.

 

Cheers

Peter

 

Prof Peter Cuttance

Director

Research Australia Development and Innovation Institute (radii.org)

Ph.    +613 9534 2934

Mob. +61 428 990 904

Fax.   +613 8640 0741

Suite 71

197 Canterbury Road

St Kilda West

Victoria AUSTRALIA 3182

 



 

On 29/01/2010, at 4:45 AM, Dennis Deck wrote:



Sounds like you really want one table at a time then

I would use something like:

 

TEMPORARY .

SELECT IF (SubjectID= ) .

(table syntax here)

 

Or use FILTER rather then the SELECT IF

 

You can use DO REPEAT logic if you have many tables to generate:

Or can embed the CTABLES command in a macro

 

DO REPEAT s =  subject1 subject2  . . .  .

+  TEMPORARY .

+ SELECT IF (SubjectID=s) .

+  (table command here)

END REPEAT .

 

Note that SELECT IF and FILTER do not require data to be presorted as SPLIT FILES does.

I rarely use SPLIT FILES personally as my break vars are often not usually mutually exclusive

 

Dennis


From: Peter Cuttance [[hidden email]] 
Sent: Thursday, January 28, 2010 3:44 AM
To: Dennis Deck
Subject: Re: CTABLES Problem

 

Hi Dennis

 

SUBJECTID is the ID for the subject the student is studying — each student has responded to a standard survey for each subject they have studied.  

 

Dropping BY BY and replacing it with BY simply results in a table that is N tables wide (where N is the number of separate SUBJECTID's.

 

I want a separate set of table results for the survey for each SUBJECTID — nornally this would be achieved by SPLIT FILE BY SUBJECTID, but this is not supported in CTABLES.

 

Any suggestions would be welcome.

 

Regards

Peter

 

Research Australia Development and Innovation Institute (radii.org)

Ph.    +613 9534 2934

Mob. +61 428 990 904

Fax.   +613 8640 0741

Suite 71

197 Canterbury Road

St Kilda West

Victoria AUSTRALIA 3182

 




 

On 28/01/2010, at 4:59 PM, Dennis Deck wrote:




Not sure why you are trying “BY BY” — a single “BY” is the proper syntax.

 

Perhaps you have a good reason to break the summary by SUBJECTID but it seems suspect.

Do you have more than one case per subject?  And why would you average by subject anyway?

I would expect a variable like Group or StudyCondition or Time . . ..

 

A simple command for checking results, of course, would be:

 

CROSSTABS

   Tables=  R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1

                      R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1 by Group

  /Cells= Count  Row  .

 

 

Dennis Deck

RMC Research

 


From: Peter Cuttance [[hidden email]] 
Sent: Wednesday, January 27, 2010 12:48 PM
Subject: CTABLES Problem

 

Can anyone tell me why the syntax below is producing the table for only one of the values of SUBJECTID?

 

I am using BY BY SUBJECTID in lieu of SPLIT FILE BY SUBJECTID which is not supported.

 

CTABLES

  /VLABELS VARIABLES=R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1

    DISPLAY=LABEL

  /TABLE (R1_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R2_1 [COUNT F40.0,  ROWPCT.COUNT PCT40.0] 

  + R3_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R4_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R5_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R6_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R7_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R8_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R9_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R10_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R11_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R12_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R13_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R14_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R15_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R17_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R18_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R19_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R20_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R21_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]) BY BY SUBJECTID

  /SLABELS POSITION=ROW VISIBLE=YES

  /CLABELS ROWLABELS=OPPOSITE

  /CATEGORIES VARIABLES=SUBJECTID R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1 ORDER=A KEY=LABEL MISSING=EXCLUDE EMPTY=EXCLUDE.

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: CTABLES Problem

Jon K Peck

If you don't mind doing a data pass for each subjectid, there is a simple solution using programmability.
Here's an example using the cars.sav file.

begin program.
import spss, spssaux2
cmd="""CTABLES
  /VLABELS VARIABLES=year origin DISPLAY=DEFAULT
  /TABLE year [COUNT F40.0] by cylinder"""
spssaux2.generalizedSplit("origin", cmd, vartype=0)
end program.

cmd is whatever syntax you want.
generalizedSplit is a function in the spssaux2.py module available from SPSS Developer Central.  In this case, I'm splitting on the origin variable.  vartype=0 means that the split variable is numeric.
Data do not need to be sorted.

Regards,

Jon Peck
SPSS, an IBM Company
[hidden email]
312-651-3435



From: Dennis Deck <[hidden email]>
To: [hidden email]
Date: 01/28/2010 03:28 PM
Subject: Re: [SPSSX-L] CTABLES Problem
Sent by: "SPSSX(r) Discussion" <[hidden email]>





If you have a list of the subjects (SUBJECTID) then simply copy that into the DO REPEAT logic.
DO REPEAT s =  subject1 subject2  . . .  .
Takes all of 2 minutes
 
You might be able to get CTABLES to place the next subject below rather than to the right.
One thought was to add a dummy variable to force CTABLES to put the next subject below rather to the right
(not sure if that will work but easy to try)
COMPUTE Dummy = 1 .
CTABLES  . . .
 ..   BY Dummy BY SubjectID .
 
Dennis



From: Peter Cuttance [mailto:cuttance@...]
Sent:
Thursday, January 28, 2010 11:08 AM
To:
Dennis Deck
Subject:
Re: CTABLES Problem

 
Hi Dennis
 
That would work OK — but, there are 300+ tables, so I am looking for something less laborious.
 
Cheers
Peter
 
Prof Peter Cuttance
Director
Research Australia Development and Innovation Institute (radii.org)
Ph.    +613 9534 2934
Mob. +61 428 990 904
Fax.   +613 8640 0741
Suite 71
197 Canterbury Road
St Kilda West
Victoria AUSTRALIA 3182
 


 
On 29/01/2010, at 4:45 AM, Dennis Deck wrote:


Sounds like you really want one table at a time then
I would use something like:
 
TEMPORARY .
SELECT IF (SubjectID= ) .
(table syntax here)
 
Or use FILTER rather then the SELECT IF
 
You can use DO REPEAT logic if you have many tables to generate:
Or can embed the CTABLES command in a macro
 
DO REPEAT s =  subject1 subject2  . . .  .
+  TEMPORARY .
+ SELECT IF (SubjectID=s) .
+  (table command here)
END REPEAT .
 
Note that SELECT IF and FILTER do not require data to be presorted as SPLIT FILES does.
I rarely use SPLIT FILES personally as my break vars are often not usually mutually exclusive
 
Dennis



From: Peter Cuttance [mailto:cuttance@...]
Sent:
Thursday, January 28, 2010 3:44 AM
To:
Dennis Deck
Subject:
Re: CTABLES Problem

 
Hi Dennis
 
SUBJECTID is the ID for the subject the student is studying — each student has responded to a standard survey for each subject they have studied.  
 
Dropping BY BY and replacing it with BY simply results in a table that is N tables wide (where N is the number of separate SUBJECTID's.
 
I want a separate set of table results for the survey for each SUBJECTID — nornally this would be achieved by SPLIT FILE BY SUBJECTID, but this is not supported in CTABLES.
 
Any suggestions would be welcome.
 
Regards
Peter
 
Research Australia Development and Innovation Institute (radii.org)
Ph.    +613 9534 2934
Mob. +61 428 990 904
Fax.   +613 8640 0741
Suite 71
197 Canterbury Road
St Kilda West
Victoria AUSTRALIA 3182
 



 
On 28/01/2010, at 4:59 PM, Dennis Deck wrote:



Not sure why you are trying “BY BY” — a single “BY” is the proper syntax.
 
Perhaps you have a good reason to break the summary by SUBJECTID but it seems suspect.
Do you have more than one case per subject?  And why would you average by subject anyway?
I would expect a variable like Group or StudyCondition or Time . . ..
 
A simple command for checking results, of course, would be:
 
CROSSTABS
   Tables=  R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1
                      R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1 by Group
  /Cells= Count  Row  .
 
 
Dennis Deck
RMC Research
 



From: Peter Cuttance [mailto:cuttance@...]
Sent:
Wednesday, January 27, 2010 12:48 PM
Subject:
CTABLES Problem

 
Can anyone tell me why the syntax below is producing the table for only one of the values of SUBJECTID?
 
I am using BY BY SUBJECTID in lieu of SPLIT FILE BY SUBJECTID which is not supported.
 
CTABLES
  /VLABELS VARIABLES=R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1
    DISPLAY=LABEL
  /TABLE (R1_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R2_1 [COUNT F40.0,  ROWPCT.COUNT PCT40.0]
  + R3_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R4_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R5_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R6_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R7_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R8_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R9_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R10_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R11_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R12_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R13_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R14_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R15_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R17_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R18_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R19_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R20_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]
  + R21_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]) BY BY SUBJECTID
  /SLABELS POSITION=ROW VISIBLE=YES
  /CLABELS ROWLABELS=OPPOSITE
  /CATEGORIES VARIABLES=SUBJECTID R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1 ORDER=A KEY=LABEL MISSING=EXCLUDE EMPTY=EXCLUDE.
 
 
 

Reply | Threaded
Open this post in threaded view
|

Re: CTABLES Problem

Ruben Geert van den Berg
In reply to this post by Dennis Deck
Dear Dennis,
 
DO REP is not going to work here. To the best of my knowledge you can only use it for data transformations, not for generating any output. You could use a very simple macro in order to accomplish this task.
 
HTH and have a shiny happy weekend ;-D
 
*Generate fake data.
 
inp pro.
loop id=1 to 30.
end cas.
end loop.
end fil.
end inp pro.
ran id
/nti (3).
ren var nid=group.
comp v1=rv.ber(.4).
comp v2=rv.ber(.6).
exe.
 
*Do rep won't work but will delete all data.
 
*do rep a=1 to 3.
*temp.
*sel if group=a.
*cro v1 by v2.
*end rep.
*exe.
 
*Very ugly macro definition.
 
define !cross()
!do !i = 1 !to 3
temp.
sel if group=!i.
cro v1 by v2.
!doend
!end.
 
*Macro call will now generate desired output.
 
!cross.


Ruben van den Berg

Methodologist

TNS NIPO

E: [hidden email]

P: +31 20 522 5738

I: www.tns-nipo.com




 

Date: Thu, 28 Jan 2010 18:08:50 +0000
From: [hidden email]
Subject: FW: CTABLES Problem
To: [hidden email]

Sounds like you really want one table at a time then

I would use something like:

 

TEMPORARY .

SELECT IF (SubjectID= ) .

(table syntax here)

 

Or use FILTER rather then the SELECT IF

 

You can use DO REPEAT logic if you have many tables to generate:

Or can embed the CTABLES command in a macro

 

DO REPEAT s =  subject1 subject2  . . .  .

+  TEMPORARY .

+ SELECT IF (SubjectID=s) .

+  (table command here)

END REPEAT .

 

Note that SELECT IF and FILTER do not require data to be presorted as SPLIT FILES does.

I rarely use SPLIT FILES personally as my break vars are often not usually mutually exclusive

 

Dennis


From: Peter Cuttance [mailto:[hidden email]]
Sent: Thursday, January 28, 2010 3:44 AM
To: Dennis Deck
Subject: Re: CTABLES Problem

 

Hi Dennis

 

SUBJECTID is the ID for the subject the student is studying — each student has responded to a standard survey for each subject they have studied.  

 

Dropping BY BY and replacing it with BY simply results in a table that is N tables wide (where N is the number of separate SUBJECTID's.

 

I want a separate set of table results for the survey for each SUBJECTID — nornally this would be achieved by SPLIT FILE BY SUBJECTID, but this is not supported in CTABLES.

 

Any suggestions would be welcome.

 

Regards

Peter

 

Research Australia Development and Innovation Institute (radii.org)

Ph.    +613 9534 2934

Mob. +61 428 990 904

Fax.   +613 8640 0741

Suite 71

197 Canterbury Road

St Kilda West

Victoria AUSTRALIA 3182

 




 

On 28/01/2010, at 4:59 PM, Dennis Deck wrote:

 

Not sure why you are trying “BY BY” — a single “BY” is the proper syntax.

 

Perhaps you have a good reason to break the summary by SUBJECTID but it seems suspect.

Do you have more than one case per subject?  And why would you average by subject anyway?

I would expect a variable like Group or StudyCondition or Time . . ..

 

A simple command for checking results, of course, would be:

 

CROSSTABS

   Tables=  R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1

                      R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1 by Group

  /Cells= Count  Row  .

 

 

Dennis Deck

RMC Research

 


From: Peter Cuttance [[hidden email]] 
Sent: Wednesday, January 27, 2010 12:48 PM
Subject: CTABLES Problem

 

Can anyone tell me why the syntax below is producing the table for only one of the values of SUBJECTID?

 

I am using BY BY SUBJECTID in lieu of SPLIT FILE BY SUBJECTID which is not supported.

 

CTABLES

  /VLABELS VARIABLES=R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1

    DISPLAY=LABEL

  /TABLE (R1_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R2_1 [COUNT F40.0,  ROWPCT.COUNT PCT40.0] 

  + R3_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R4_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R5_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R6_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R7_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R8_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R9_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R10_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R11_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R12_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R13_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R14_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R15_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R17_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R18_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R19_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R20_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0] 

  + R21_1 [COUNT F40.0, ROWPCT.COUNT PCT40.0]) BY BY SUBJECTID

  /SLABELS POSITION=ROW VISIBLE=YES

  /CLABELS ROWLABELS=OPPOSITE

  /CATEGORIES VARIABLES=SUBJECTID R1_1 R2_1 R3_1 R4_1 R5_1 R6_1 R7_1 R8_1 R9_1 R10_1 R11_1 R12_1 R13_1 R14_1 R15_1 R17_1 R18_1 R19_1 R20_1 R21_1 ORDER=A KEY=LABEL MISSING=EXCLUDE EMPTY=EXCLUDE.

 

 



Express yourself instantly with MSN Messenger! MSN Messenger
Reply | Threaded
Open this post in threaded view
|

Re: CTABLES Problem

Bruce Weaver
Administrator
Ruben van den Berg wrote
Dear Dennis,

DO REP is not going to work here. To the best of my knowledge you can only use it for data transformations, not for generating any output. You could use a very simple macro in order to accomplish this task.

HTH and have a shiny happy weekend ;-D


*Generate fake data.

inp pro.
loop id=1 to 30.
end cas.
end loop.
end fil.
end inp pro.
ran id
/nti (3).
ren var nid=group.
comp v1=rv.ber(.4).
comp v2=rv.ber(.6).
exe.

*Do rep won't work but will delete all data.

*do rep a=1 to 3.
*temp.
*sel if group=a.
*cro v1 by v2.
*end rep.
*exe.

*Very ugly macro definition.

define !cross()
!do !i = 1 !to 3
temp.
sel if group=!i.
cro v1 by v2.
!doend
!end.

*Macro call will now generate desired output.

!cross.
Or alternatively...

sort cases by group.
split file by group.
crosstabs v1 by v2.
split file off.

I assume CTABLES works with SPLIT FILE, does it not?  

--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).