Coloring the tables based on sig t

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

Coloring the tables based on sig t

Arora, Manoj (IMDLR)

Hi All,

 

I am using SPSS 22 and after using SPSS Merge Table I am using SPSS Modify table to color the background of cell if it is significant. It is merging but it is nor coloring. Please let me know whether this utility works in SPSS 22 or not. I am using customerstylefunctions.py.

 

 

Output generated is show below with syntax and data file

 

 

 

 

DIVISIONSEGMENT

1.00 BRANCH FUNCTIONS

2.00 BUILDING SEGMENT

3.00 CABLE

4.00 CRI

5.00 ECD

6.00 HO FUNCTIONS

7.00 INDUSTRIAL PRODUCT

8.00 LIGHTING

9.00 MANUFACTURING

10.00 SALES COMMON

11.00 STANDARD

gendor

1.00 FEMALE

Column N %

4.9%

0.5%

6.5%

8.8%

B

1.2%

10.0%

B E

0.0%

1.8%

5.7%

B

0.0%

0.0%

2.00 MALE

Column N %

95.1%

99.5%

D F I

93.5%

91.3%

98.8%

F

90.0%

100.0%

98.2%

94.3%

100.0%

100.0%

 

Results are based on two-sided tests with significance level .05. For each significant pair, the key of the category with the smaller column proportion appears under the category with the larger column proportion.

 

 

Syntax is below

 

CTABLES

  /VLABELS VARIABLES=gendor div_seg DISPLAY=LABEL

  /TABLE gendor [C][COLPCT.COUNT PCT40.1] BY div_seg [C]

  /SLABELS POSITION=ROW

  /CATEGORIES VARIABLES=gendor div_seg ORDER=A KEY=VALUE EMPTY=INCLUDE

  /COMPARETEST TYPE=PROP ALPHA=0.05 ADJUST=BONFERRONI ORIGIN=COLUMN INCLUDEMRSETS=YES

    CATEGORIES=ALLVISIBLE MERGE=NO.

 

SPSSINC MERGE TABLES MATCHLABEL="Column N %" ATTACH=Rows MODE=MERGE  COLFUNCTION="SPSSINC_MERGE_TABLES.colfuncbynumber"

/OPTIONS HIDE=Yes APPENDTITLE=No APPENDCAPTION=Yes ADDLABELLEAF=Yes HALIGN=Right SEPARATOR="\n".

 

SPSSINC MODIFY TABLES subtype="CustomTable" SELECT="ALL"  DIMENSION= COLUMNS LEVEL = -1  SIGLEVELS=BOTH PROCESS = PRECEDING

/STYLES  APPLYTO=DATACELLS BACKGROUNDCOLOR=255 0 0

CUSTOMFUNCTION="customstylefunctions.colorIfEndsWithAtoZLetter".

 

 

Regards

Manoj

 



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

Re: Coloring the tables based on sig t

Jon Peck
Close, but there are a few problems with the syntax.  Since you are using the older significance format, you need to pass the
desired colors as parameters to the colorIfEndsWithAtoZ rather than specifying the BACKGROUND parameter in the STYLES
subcomand.

More importantly, you need to specify the SELECT keyword as "<<ALL>>" rather than as above.  You are getting no result because
there are no column labels that match the string "ALL".

Putting this together, the syntax should be
SPSSINC MODIFY TABLES subtype="CustomTable" SELECT="<<ALL>>"  DIMENSION= COLUMNS  PROCESS = PRECEDING
/STYLES  APPLYTO=DATACELLS 
CUSTOMFUNCTION="customstylefunctions.colorIfEndsWithAtoZLetter(r=255,g=0,b=0)".



On Thu, Sep 27, 2018 at 4:24 AM Arora, Manoj (IMDLR) <[hidden email]> wrote:

Hi All,

 

I am using SPSS 22 and after using SPSS Merge Table I am using SPSS Modify table to color the background of cell if it is significant. It is merging but it is nor coloring. Please let me know whether this utility works in SPSS 22 or not. I am using customerstylefunctions.py.

 

 

Output generated is show below with syntax and data file

 

 

 

 

DIVISIONSEGMENT

1.00 BRANCH FUNCTIONS

2.00 BUILDING SEGMENT

3.00 CABLE

4.00 CRI

5.00 ECD

6.00 HO FUNCTIONS

7.00 INDUSTRIAL PRODUCT

8.00 LIGHTING

9.00 MANUFACTURING

10.00 SALES COMMON

11.00 STANDARD

gendor

1.00 FEMALE

Column N %

4.9%

0.5%

6.5%

8.8%

B

1.2%

10.0%

B E

0.0%

1.8%

5.7%

B

0.0%

0.0%

2.00 MALE

Column N %

95.1%

99.5%

D F I

93.5%

91.3%

98.8%

F

90.0%

100.0%

98.2%

94.3%

100.0%

100.0%

 

Results are based on two-sided tests with significance level .05. For each significant pair, the key of the category with the smaller column proportion appears under the category with the larger column proportion.

 

 

Syntax is below

 

CTABLES

  /VLABELS VARIABLES=gendor div_seg DISPLAY=LABEL

  /TABLE gendor [C][COLPCT.COUNT PCT40.1] BY div_seg [C]

  /SLABELS POSITION=ROW

  /CATEGORIES VARIABLES=gendor div_seg ORDER=A KEY=VALUE EMPTY=INCLUDE

  /COMPARETEST TYPE=PROP ALPHA=0.05 ADJUST=BONFERRONI ORIGIN=COLUMN INCLUDEMRSETS=YES

    CATEGORIES=ALLVISIBLE MERGE=NO.

 

SPSSINC MERGE TABLES MATCHLABEL="Column N %" ATTACH=Rows MODE=MERGE  COLFUNCTION="SPSSINC_MERGE_TABLES.colfuncbynumber"

/OPTIONS HIDE=Yes APPENDTITLE=No APPENDCAPTION=Yes ADDLABELLEAF=Yes HALIGN=Right SEPARATOR="\n".

 

SPSSINC MODIFY TABLES subtype="CustomTable" SELECT="ALL"  DIMENSION= COLUMNS LEVEL = -1  SIGLEVELS=BOTH PROCESS = PRECEDING

/STYLES  APPLYTO=DATACELLS BACKGROUNDCOLOR=255 0 0

CUSTOMFUNCTION="customstylefunctions.colorIfEndsWithAtoZLetter".

 

 

Regards

Manoj

 



Kantar Disclaimer
===================== 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 K Peck
[hidden email]

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

Re: Coloring the tables based on sig t

Ki Park
Hi Jon,
I have been following these two threads and when I use this code, to
"MERGE=YES" when making the Ctable, the MODIFY TABLE does not work.

CTABLES
  /VLABELS  VARIABLES=income age DISPLAY=NONE
  /TABLE income [C][COLPCT.COUNT PCT40.1]  by age
  /SLABELS POSITION=ROW
  /CATEGORIES VARIABLES=income age ORDER=A KEY=VALUE EMPTY=INCLUDE
MISSING=EXCLUDE
  /CRITERIA CILEVEL=95
  /COMPARETEST TYPE=PROP ALPHA=0.05 ADJUST=BONFERRONI ORIGIN=COLUMN
INCLUDEMRSETS=YES
    CATEGORIES=ALLVISIBLE MERGE=YES STYLE=SIMPLE SHOWSIG=no.

SPSSINC MODIFY TABLES subtype="CustomTable" SELECT="<<ALL>>"  DIMENSION=
COLUMNS  PROCESS = PRECEDING
/STYLES  APPLYTO=DATACELLS
CUSTOMFUNCTION="customstylefunctions.colorIfEndsWithAtoZLetter(r=255,g=0,b=0)".


It works when you do in 'steps' like this.

CTABLES
  /VLABELS  VARIABLES=income age DISPLAY=NONE
  /TABLE income [C][COLPCT.COUNT PCT40.1]  by age
  /SLABELS POSITION=ROW
  /CATEGORIES VARIABLES=income age ORDER=A KEY=VALUE EMPTY=INCLUDE
MISSING=EXCLUDE
  /CRITERIA CILEVEL=95
  /COMPARETEST TYPE=PROP ALPHA=0.05 ADJUST=BONFERRONI ORIGIN=COLUMN
INCLUDEMRSETS=YES
    CATEGORIES=ALLVISIBLE MERGE=no SHOWSIG=no.

SPSSINC MERGE TABLES MATCHLABEL="Column N %" ATTACH=rows MODE=MERGE
/OPTIONS HIDE=no APPENDTITLE=No APPENDCAPTION=Yes ADDLABELLEAF=Yes
HALIGN=RIGHT SEPARATOR="\n" .

SPSSINC MODIFY TABLES subtype="CustomTable" SELECT="<<ALL>>"  DIMENSION=
COLUMNS  PROCESS = PRECEDING
/STYLES  APPLYTO=DATACELLS
CUSTOMFUNCTION="customstylefunctions.colorIfEndsWithAtoZLetter(r=255,g=0,b=0)".

I am just curious why is this first combination does not work.

Ki




--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: Coloring the tables based on sig t

Jon Peck
When you display the significance indicators directly with CTABLES (MERGE=YES STYLE=SIMPLE), the cells are actually different from the two table version with the merging by MERGE TABLES even though they look about the same.  The significance indicator is sort of a superscript rather than a value in the cell.  You will see this if you double click a cell with a marker in the pivot table editor.

The MODIFY TABLES custom function works on letters that are actually present in the cells as regular text, and it doesn't find any of these.

Of course, you don't need that function in this case, since the indicators already appear in the cells, but you  can use new functionality in MODIFY TABLES as of V24 to format these cells.  From the syntax help...

SIGLEVELS This keyword narrows the selection made on the main dialog to those cells that meet the significance criteria specified here. In most cases, the significance criteria would be used with the "<<ALL>>" selection specification, but if there is a subset selected there, the significance specifications are applied within that.

This keyword applies only to Statistics version 24 or later and to output from Custom Tables (CTABLES) where significance markers are shown in the main table and are the simple (not APA) type.

ALLSIG selects all cells with any significance marker. Significance markers are special letter codes that appear in the cell

Alternatively, you can specify the specific significance markers to be selected by entering a significance pattern. The pattern can be a simple list of the column markers. For example, "AB" would select only cells where columns lettered A or B are listed as significantly different. The letter codes are shown in the column headers when significance results are merged rather than being shown in a separate table. You might use this when you want to focus on a few specific categories.

Subtables across the columns occur when the column dimension has a nested specification such as job category within gender (gender > jobcat), or when there are multiple categorical variables stacked in that dimension (jobcat + gender). You can further specify which subtables the selection applies to by listing the subtable numbers after each letter code. For example, A01B2 indicates that only A-significant cells should be selected in subtables 0 and 1 and only B-significant codes should be selected in subtable 2. You can identify subtables in the output, because the column lettering for significance restarts from (A) across the table for each subtable.

In a nested table, the innermost dimension repeats, so you would probably want the selection to apply across all the nested subtables. However, if variables are stacked across the columns, the meaning of the significance letters will be different in each subtable, and you might want the selection to apply only to particular subtables.

Subtable numbering starts from 0. Up to ten subtables can be referenced using this notation.

SIGLEVELS specifies which significance levels should be selected. One or two significance levels can be shown in a table. If there are two, the more significant values are indicated in upper case letters and the less significant in lower case. In selecting, you can specify that both levels are selected or that only one or the other is selected. If there is only one level in the table, choose BOTH or UPPER.


On Thu, Sep 27, 2018 at 2:16 PM Ki Park <[hidden email]> wrote:
Hi Jon,
I have been following these two threads and when I use this code, to
"MERGE=YES" when making the Ctable, the MODIFY TABLE does not work.

CTABLES
  /VLABELS  VARIABLES=income age DISPLAY=NONE
  /TABLE income [C][COLPCT.COUNT PCT40.1]  by age
  /SLABELS POSITION=ROW
  /CATEGORIES VARIABLES=income age ORDER=A KEY=VALUE EMPTY=INCLUDE
MISSING=EXCLUDE
  /CRITERIA CILEVEL=95
  /COMPARETEST TYPE=PROP ALPHA=0.05 ADJUST=BONFERRONI ORIGIN=COLUMN
INCLUDEMRSETS=YES
    CATEGORIES=ALLVISIBLE MERGE=YES STYLE=SIMPLE SHOWSIG=no.

SPSSINC MODIFY TABLES subtype="CustomTable" SELECT="<<ALL>>"  DIMENSION=
COLUMNS  PROCESS = PRECEDING
/STYLES  APPLYTO=DATACELLS
CUSTOMFUNCTION="customstylefunctions.colorIfEndsWithAtoZLetter(r=255,g=0,b=0)".


It works when you do in 'steps' like this.

CTABLES
  /VLABELS  VARIABLES=income age DISPLAY=NONE
  /TABLE income [C][COLPCT.COUNT PCT40.1]  by age
  /SLABELS POSITION=ROW
  /CATEGORIES VARIABLES=income age ORDER=A KEY=VALUE EMPTY=INCLUDE
MISSING=EXCLUDE
  /CRITERIA CILEVEL=95
  /COMPARETEST TYPE=PROP ALPHA=0.05 ADJUST=BONFERRONI ORIGIN=COLUMN
INCLUDEMRSETS=YES
    CATEGORIES=ALLVISIBLE MERGE=no SHOWSIG=no.

SPSSINC MERGE TABLES MATCHLABEL="Column N %" ATTACH=rows MODE=MERGE
/OPTIONS HIDE=no APPENDTITLE=No APPENDCAPTION=Yes ADDLABELLEAF=Yes
HALIGN=RIGHT SEPARATOR="\n" .

SPSSINC MODIFY TABLES subtype="CustomTable" SELECT="<<ALL>>"  DIMENSION=
COLUMNS  PROCESS = PRECEDING
/STYLES  APPLYTO=DATACELLS
CUSTOMFUNCTION="customstylefunctions.colorIfEndsWithAtoZLetter(r=255,g=0,b=0)".

I am just curious why is this first combination does not work.

Ki




--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

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