Cookies help us display personalized product recommendations and ensure you have great shopping experience.

By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData CollectiveSmartData Collective
  • Analytics
    AnalyticsShow More
    How Data Analytics Is Reshaping Patient Financing Decisions
    How Data Analytics Is Reshaping Patient Financing Decisions
    13 Min Read
    business using business intelligence
    How to Use a Competitive Intelligence Dashboard to Turn Market Data Into Smarter Marketing Decisions 
    9 Min Read
    unusual trading activity
    Signal Or Noise? A Decision Tree For Evaluating Unusual Trading Activity
    3 Min Read
    software developer using ai
    How Data Analytics Helps Developers Deliver Better Tech Services
    8 Min Read
    ai for stock trading
    Can Data Analytics Help Investors Outperform Warren Buffett
    9 Min Read
  • Big Data
  • BI
  • Exclusive
  • IT
  • Marketing
  • Software
Search
© 2008-25 SmartData Collective. All Rights Reserved.
Reading: From Prettier Tables to Prettier Text
Share
Notification
Font ResizerAa
SmartData CollectiveSmartData Collective
Font ResizerAa
Search
  • About
  • Help
  • Privacy
Follow US
© 2008-23 SmartData Collective. All Rights Reserved.
SmartData Collective > Uncategorized > From Prettier Tables to Prettier Text
Uncategorized

From Prettier Tables to Prettier Text

Editor SDC
Editor SDC
6 Min Read
SHARE

“Pretty” understates what formatting is really about. Making an object more pleasing to the eye is nice, but the point is really about communicating better with the reader of the output. Formatting the output appropriately can improve that process. In previous posts, I have written about ways to format pivot tables: the […]

“Pretty” understates what formatting is really about. Making an object more pleasing to the eye is nice, but the point is really about communicating better with the reader of the output. Formatting the output appropriately can improve that process. In previous posts, I have written about ways to format pivot tables: the most important textual output from SPSS. In this post, I will discuss a way to create and format text blocks.

Inexplicably, SPSS has never had a good, built-in, production way of writing a block of text to the Viewer. Syntax can be echoed to a log file, including the COMMENT command, but logs are full of other things and don’t work well for communicating with readers, especially if they are not conversant with SPSS syntax. You can, of course, interactively insert a text block in the Viewer, but that’s a non-starter for production work. There are scripting apis for text blocks, too, but they require a knowledge of script programming.

For this reason, I created the TEXT extension command. (Recall that extension commands are user-defined commands that can be installed and are then available like regular commands.) TEXT takes a list of literals and creates a new text block object in the Viewer with each literal as a line. You can control the outline text and title information for the block as well. That works with Version 16 or later. With Version 17, though, you can present this text better by adding formatting.

More Read

Social Media in One Word
How to Convince Your Executive Team to Update Your Technology
A New Open Journal on Data Science
Mobile, Mobile, Mobile!
Tracking the data trackers

To do that, all you have to do is to create the text as html or rtf and feed it to the TEXT command. Here’s an example.

TEXT "<html>The following table is " 
"<font size=6><b><i>confidential</i></b> </font>.<br> "
"It must not be shared outside the company</html>"
/OUTLINE HEADING="Notice".

Here’s what the resulting text block looks like.

A Formatted Text Block

A Formatted Text Block

The principle is that if the text looks like html or rtf, it will be treated as formatted text; otherwise, it will be considered to be plain. For html, this means starting with <html> in lower case. This example specifies the “confidential” text to be size 6 (html sizes go from 1 to 7), bold, and italic. It also inserts a line break. A web search on html will produce many pages to explain the html markup language. One good introduction is Introduction to Html.

The text in this example is split into several strings. Because it is formatted, the strings are joined without any added spaces or line breaks. Html directives such as <br> would be used to break lines if needed.

Basic html is simple to write, and there are plenty of free html editors you can use, or just use a plain text editor, but keep the html simple. Only basic formatting is supported. Don’t use Microsoft Word to create the html: it creates very complex and hard-to-process html. For rtf, you might use a program like WordPad to create the rtf and then copy it into your syntax, but rtf is quite complex, and it makes your syntax very hard to read, so I recommend sticking with html.

The TEXT extension command can be downloaded from SPSS Developer Central. It requires the Python programmability Plug-In. The same download works for Versions 16 and 17, but with Version 16, only plain text can be inserted.

Formatting the Outline and Titles

Rather to my surprise, I learned that some users spend a lot of time structuring and formatting the Viewer outline and headings and titles. I created the extension command SPSSINC MODIFY OUTPUT to eliminate the complexity and drudgery in that work.

It’s not well known, but title and heading objects in the Viewer can be formatted with html or rtf in the same way as I just described for text blocks: if the text looks like html or rtf, it is treated that way. The text generated by SPSS procedures, though, doesn’t include such formatting. SPSSINC MODIFY OUTPUT can upgrade the text, and it can do other things to output objects. More on that in my next post.

Share This Article
Facebook Pinterest LinkedIn
Share

Follow us on Facebook

Latest News

How Data Analytics Is Reshaping Patient Financing Decisions
How Data Analytics Is Reshaping Patient Financing Decisions
Analytics Big Data Exclusive
AI driven big data company
How AI-Driven Workflows Are Changing the Way Companies Think About Data Risk
Artificial Intelligence Data Management Exclusive Risk Management
ai product development
Why Businesses Outsource AI Product Development Companies
Exclusive News
banking tools
The Fintech and Banking Tools Global Entrepreneurs Rely On
Fintech Infographic

Stay Connected

1.2KFollowersLike
33.7KFollowersFollow
222FollowersPin

You Might also Like

A Brief Introduction to Knowledge Management [SLIDESHARE]

0 Min Read

Interactive Intelligence Reveals Ambitious Plans for Customer Service

0 Min Read

One Hit Wonders

3 Min Read

Is the Information Retrieval Community Making Progress?

0 Min Read

SmartData Collective is one of the largest & trusted community covering technical content about Big Data, BI, Cloud, Analytics, Artificial Intelligence, IoT & more.

ai in ecommerce
Artificial Intelligence for eCommerce: A Closer Look
Artificial Intelligence
AI and chatbots
Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
Artificial Intelligence Chatbots Exclusive

Quick Link

  • About
  • Contact
  • Privacy
Follow US
© 2008-25 SmartData Collective. All Rights Reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?