By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData Collective
  • Analytics
    AnalyticsShow More
    data analytics in sports industry
    Here’s How Data Analytics In Sports Is Changing The Game
    6 Min Read
    data analytics on nursing career
    Advances in Data Analytics Are Rapidly Transforming Nursing
    8 Min Read
    data analytics reveals the benefits of MBA
    Data Analytics Technology Proves Benefits of an MBA
    9 Min Read
    data-driven image seo
    Data Analytics Helps Marketers Substantially Boost Image SEO
    8 Min Read
    construction analytics
    5 Benefits of Analytics to Manage Commercial Construction
    5 Min Read
  • Big Data
  • BI
  • Exclusive
  • IT
  • Marketing
  • Software
Search
© 2008-23 SmartData Collective. All Rights Reserved.
Reading: From Prettier Tables to Prettier Text
Share
Notification Show More
Latest News
big data mac performance
Data-Driven Tips to Optimize the Speed of Macs
News
3 Ways AI Has Helped Marketers and Creative Professionals Streamline Workflows
3 Ways AI Has Helped Marketers and Creative Professionals Streamline Workflows
Artificial Intelligence
data analytics in sports industry
Here’s How Data Analytics In Sports Is Changing The Game
Big Data
data analytics on nursing career
Advances in Data Analytics Are Rapidly Transforming Nursing
Analytics
data analytics reveals the benefits of MBA
Data Analytics Technology Proves Benefits of an MBA
Analytics
Aa
SmartData Collective
Aa
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
Last updated: 2009/04/22 at 11:26 AM
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

big data improves

3 Ways Big Data Improves Leadership Within Companies

IT Is Not Analytics. Here’s Why.
Romney Invokes Analytics in Rebuke of Trump
WEF Davos 2016: Top 100 CEO bloggers
In Memoriam: Robin Fray Carey

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.

Editor SDC April 22, 2009
Share this Article
Facebook Twitter Pinterest LinkedIn
Share

Follow us on Facebook

Latest News

big data mac performance
Data-Driven Tips to Optimize the Speed of Macs
News
3 Ways AI Has Helped Marketers and Creative Professionals Streamline Workflows
3 Ways AI Has Helped Marketers and Creative Professionals Streamline Workflows
Artificial Intelligence
data analytics in sports industry
Here’s How Data Analytics In Sports Is Changing The Game
Big Data
data analytics on nursing career
Advances in Data Analytics Are Rapidly Transforming Nursing
Analytics

Stay Connected

1.2k Followers Like
33.7k Followers Follow
222 Followers Pin

You Might also Like

big data improves
Big DataJobsKnowledge ManagementUncategorized

3 Ways Big Data Improves Leadership Within Companies

6 Min Read
Image
Uncategorized

IT Is Not Analytics. Here’s Why.

7 Min Read

Romney Invokes Analytics in Rebuke of Trump

4 Min Read

WEF Davos 2016: Top 100 CEO bloggers

14 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 and chatbots
Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
Artificial Intelligence Chatbots Exclusive
AI chatbots
AI Chatbots Can Help Retailers Convert Live Broadcast Viewers into Sales!
Chatbots

Quick Link

  • About
  • Contact
  • Privacy
Follow US

© 2008-23 SmartData Collective. All Rights Reserved.

Removed from reading list

Undo
Go to mobile version
Welcome Back!

Sign in to your account

Lost your password?