correct use of crosstabas and custom tables in segmentation

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

correct use of crosstabas and custom tables in segmentation

progster
Dear all,
I would like to analyze a trend of a variable by month and year, that is create a unique table with both 2013 and 2014 data ant the break for each month (as an Excel pivot table would do).
I tried with both cross table and custom table, but I can only obtain separate tables (only for months or for years).
Thanks in advance for every suggestion.



DATA LIST LIST
 / month year var .
BEGIN DATA.
1 2013 1
2 2013 4
3 2013 5
4 2013 6
5 2013 3
6 2013 4
7 2013 6
8 2013 7
9 2013 4
10 2013 2
11 2013 1
12 2013 5
1 2014 6
2 2014 7
3 2014 4
4 2014 3
5 2014 2
6 2014 2
7 2014 3
8 2014 3
9 2014 2
10 2014 3
END DATA.

LIST.


CROSSTABS
  /TABLES=var BY year month
  /FORMAT=AVALUE TABLES
  /CELLS=COUNT
  /COUNT ROUND CELL.

* Custom Tables.
CTABLES
  /VLABELS VARIABLES=var year month DISPLAY=LABEL
  /TABLE var BY year [COUNT F40.0] > month
  /CATEGORIES VARIABLES=var month ORDER=A KEY=VALUE EMPTY=EXCLUDE.
Reply | Threaded
Open this post in threaded view
|

Re: correct use of crosstabas and custom tables in segmentation

Bruce Weaver
Administrator
For CROSSTABS, does this give what you want?

  /TABLES=var BY month BY year

To generate this via the GUI, let Row=var, Col=month and Layer=year.


progster wrote
Dear all,
I would like to analyze a trend of a variable by month and year, that is create a unique table with both 2013 and 2014 data ant the break for each month (as an Excel pivot table would do).
I tried with both cross table and custom table, but I can only obtain separate tables (only for months or for years).
Thanks in advance for every suggestion.



DATA LIST LIST
 / month year var .
BEGIN DATA.
1 2013 1
2 2013 4
3 2013 5
4 2013 6
5 2013 3
6 2013 4
7 2013 6
8 2013 7
9 2013 4
10 2013 2
11 2013 1
12 2013 5
1 2014 6
2 2014 7
3 2014 4
4 2014 3
5 2014 2
6 2014 2
7 2014 3
8 2014 3
9 2014 2
10 2014 3
END DATA.

LIST.


CROSSTABS
  /TABLES=var BY year month
  /FORMAT=AVALUE TABLES
  /CELLS=COUNT
  /COUNT ROUND CELL.

* Custom Tables.
CTABLES
  /VLABELS VARIABLES=var year month DISPLAY=LABEL
  /TABLE var BY year [COUNT F40.0] > month
  /CATEGORIES VARIABLES=var month ORDER=A KEY=VALUE EMPTY=EXCLUDE.
--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: correct use of crosstabas and custom tables in segmentation

progster
ok for crosstabs, doesn't work with the GUI, i will try again..and again thanks
Reply | Threaded
Open this post in threaded view
|

Re: correct use of crosstabas and custom tables in segmentation

PRogman
I believe this CTables syntax replicates the CROSSTAB output.
HTH,
PR

CTABLES
  /VLABELS VARIABLES=month var year 
           DISPLAY=LABEL
  /TABLE month [C] > var [C][COUNT F40.0] BY year [C]
  /SLABELS POSITION=ROW VISIBLE=NO
  /CATEGORIES VARIABLES=month var year ORDER=A KEY=VALUE EMPTY=EXCLUDE TOTAL=YES POSITION=AFTER.
Reply | Threaded
Open this post in threaded view
|

Re: correct use of crosstabas and custom tables in segmentation

Ruben Geert van den Berg
In reply to this post by progster
"ok for crosstabs, doesn't work with the GUI..."

Figuring out the syntax for CROSSTABS (like most SPSS syntax anyway) may take you less time than figuring out the GUI for it. Consider giving it a go.

There's plenty of reasons for working from (possibly pasted) syntax. See http://www.spss-tutorials.com/spss-syntax-six-reasons-you-should-use-it/.

Reversely, I never witnessed any of my colleagues or students move in the opposite direction (from syntax back to the GUI, that is).

HTH,

Ruben