Digital Developer Conference: a FREE half-day online conference focused on AI & Cloud – North America: Nov 2 – India: Nov 9 – Europe: Nov 14 – Asia Nov 23 Register now

Close outline
  • United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

Pcompute & enforcing decimal places

270003EYSH gravatar image
Question by ckarbo  (0) | Jun 29, 2012 at 06:27 PM spssstatistics
 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.

]]

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

7 answers

  • Sort: 
110000D4XK gravatar image

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

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270003EYSH gravatar image

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

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
110000D4XK gravatar image

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

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270003EYSH gravatar image

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

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
110000D4XK gravatar image

Answer by SystemAdmin (532) | Jul 05, 2012 at 08:22 PM

 Just email it to me at<br>
  peck AT us.ibm.com
  
             
Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
110000D4XK gravatar image

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.


You can read about it in the dialog help or by running the command with /HELP, but the key point is the formula. This formula takes the first column and the last column before the Diff column, rounds each value to two decimals and subtracts. The result replaces the existing Diff values.

Try this out and see how it holds up. Remember that it is a beta test version. Pivot table structures are very complicated!

HTH,
Jon Peck
Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270003EYSH gravatar image

Answer by ckarbo (0) | Jul 26, 2012 at 10:57 PM

 Now I apologize for the delay, other project work has taken me away from this task.<br>


That appears to have done the trick! Thank you so much for your help!

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

46 people are following this question.

Answers

Answers & comments

Related questions

How to get the R Essential Analysis Features for SPSS 25 2 Answers

SPSS Licenses - reset 2 Answers

For SPSS Statistics, should the correct FCode be logged in the slm_log.txt file? 3 Answers

Transfer my SPSS Statistics License Key to new computer 1 Answer

Authorization Failed, why does the error say not allowed to generate any more new licenses? 0 Answers

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • Data and AI
  • DataPower
  • Decision Optimization
  • DevOps Build
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • Hyper Protect
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PartnerWorld Developer Support
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges