Hello,<br>
Is there a way to enforce rounding and/or decimal precision when using PCOMPUTE in a Custom Table?
I'm generating multiple reports, showing means of a dichotomous recognition variable, and calculating the difference between the rec/non. However, with PCOMPUTE I get a number that is technically accurate, but not obviously so. I've included a truncated version below (the actual table has roughly 20 some variables). Taken to 5 decimals, these are all correct. However, it won't be reported this way, and trying to convince my client that the difference between .26 and .30 is .03, or .16 and .17 is .00 is going to be a fruitless battle.
Clearly I can correct all this in Excel, but given the repetitious nature of this task, and the volume of output, I'm looking to minimize what I have to do in Excel.
Thanks for any help you can provide!
OUTPUT:
Ad Recognition: TV
No Yes Diff
Authentic/real .26a .30a .03
Inspirational .17a .23a .06
Fun .16a .17a .00
[[SYNTAX:
ctables
/pcompute &x = EXPR([1]-[0])
/pproperties &x LABEL = "Diff" FORMAT = mean f8.2
/table
qc5_1_1[s]validn+
(qc5_1_1+
qc5_1_2+
qc5_1_3+
qc5_1_4
) [s]http://mean f3.2 by qd3_top1
/CATEGORIES VARIABLES=qd3_top1 0,1,&x
/slabels position = row visible=no
/COMPARETEST TYPE= mean MERGE=yes.
]]
Answer by SystemAdmin (532) | Jun 30, 2012 at 02:03 AM
The PPROPERTIES subcommand gives you control over the formatting, so you could show another decimal place, or show another decimal in the numbers to which the PCOMPUTE is being applied. You can't use the regular transformation system functions to solve this.<br>
Other than that, you could use a small custom function with the SPSSINC MODIFY TABLES extension command to replace the Diff column with one computed more to your liking. The custom function would have to be in Python, but it would only need a few lines of code. I can help with that if you want to go this route.
HTH,
Jon Peck
Answer by ckarbo (0) | Jul 03, 2012 at 04:48 PM
Thanks Jon!<br>
I tried the PPROPERTIES. Ultimately, these are being converted to percentages, so adding the decimal places doesn't help in this specific scenario.
If you could help me with the MODIFY TABLES, that would be great. I've worked with it a little, but only to the extent of pivoting outputs, and some conditional formatting.
CK
Answer by SystemAdmin (532) | Jul 03, 2012 at 07:56 PM
If you can provide an spv file with the table you want to convert and the exact expression you want to replace the PCOMPUTE total, I'll take a look.<br>
I am working on a general extension command that can do computations over any cells in a table in a more general way than PCOMPUTE, but that probably won't be ready for a few weeks.
Regards,
Jon
Answer by ckarbo (0) | Jul 05, 2012 at 06:32 PM
Thanks Jon!<br>
I'm having a hard time attaching a file to this message. I have created a sample .spv, along with an Excel file to show what ultimately I'm trying to achieve. Is there an FTP site I can drop this to, or email?
CK
Answer by SystemAdmin (532) | Jul 05, 2012 at 08:22 PM
Just email it to me at<br>
peck AT us.ibm.com
Answer by SystemAdmin (532) | Jul 12, 2012 at 08:14 PM
Sorry I haven't gotten back to this sooner. I have been working on a general extension command that can do computations over the cells of a pivot table. I have posted a beta version of this command, which is called STATS TABLE CALC. You can get it from the Extension Commands collection on the SPSS Community site.<br>
I tested this on your sample table, and it did what I think you want. The package includes a dialog box interface, but here is the syntax I used on your table.
STATS TABLE CALC SUBTYPE=
"custom table" PROCESS=PRECEDING /TARGET FORMULA=
"round(x0,2) - round(x[-1],2)" DIMENSION=COLUMNS LEVEL = -2 LOCATION=
"Diff" LABEL=
"Diff" MODE=REPLACE.