Discussion:
How to insert a comment into output via syntax?
(too old to reply)
Haris
2006-10-12 22:18:50 UTC
Permalink
I like annotating my output and work primarily from syntax. I would
like to be able to describe the analyses as they are run. Is there a
way to insert SPSS text into the output form Syntax. I would like to
do something like this:

TEXT 'Here is what the following output is all about' .

I use TITLE and SUBTITLE extensively but they don't have enough space
for my purposes. ECHO only works if one does not use printback, which
does not work for me. I normally print syntax prior to each output,
but keep it hidden and only open it as needed. Plus, ECHO seems to be
limited to the line width and does not allow multiple lines.

So, is there a way to insert SPSS Text from syntax? If so, what is the
command? I can't seem to find it.

Thanks,
Haris
Richard Ulrich
2006-10-13 20:42:00 UTC
Permalink
Post by Haris
I like annotating my output and work primarily from syntax. I would
like to be able to describe the analyses as they are run. Is there a
way to insert SPSS text into the output form Syntax. I would like to
TEXT 'Here is what the following output is all about' .
I use TITLE and SUBTITLE extensively but they don't have enough space
for my purposes. ECHO only works if one does not use printback, which
does not work for me. I normally print syntax prior to each output,
but keep it hidden and only open it as needed. Plus, ECHO seems to be
limited to the line width and does not allow multiple lines.
So, is there a way to insert SPSS Text from syntax? If so, what is the
command? I can't seem to find it.
COMMENT this is
your comment .

Be sure to end with a period or an extra blank line -- it is
really annoying to discover that something doesn't work
because it was considered as part of a preceding 'comment'.
--
Rich Ulrich, ***@pitt.edu

http://www.pitt.edu/~wpilib/index.html
Lawrence
2006-10-14 11:16:52 UTC
Permalink
Thanks Richard,

Simple and Great..

For more detail information about COMMENT available in SPSSBASE.pdf.
page number 267.

Thanks,

Lawrence.
Haris
2006-10-15 01:31:37 UTC
Permalink
COMMENT outputs as SPSS Log in the output and does not ouput anything
if you SET PRINTBACK to OFF. I am still looking for a way to output
"SPSS Text" not "Log." Anybody know if this is possible or is SPSS
Text only available via pull-down menus?

Thanks
Post by Lawrence
Thanks Richard,
Simple and Great..
For more detail information about COMMENT available in SPSSBASE.pdf.
page number 267.
Thanks,
Lawrence.
Dick
2006-10-16 08:45:22 UTC
Permalink
I think [print /varname 'bla bla bla'.] will do the job for you.

The varname is only shown when it contains no more than 80 characters.
You can use more than one varname.

good luck.
Post by Haris
COMMENT outputs as SPSS Log in the output and does not ouput anything
if you SET PRINTBACK to OFF. I am still looking for a way to output
"SPSS Text" not "Log." Anybody know if this is possible or is SPSS
Text only available via pull-down menus?
Thanks
Post by Lawrence
Thanks Richard,
Simple and Great..
For more detail information about COMMENT available in SPSSBASE.pdf.
page number 267.
Thanks,
Lawrence.
Haris
2006-10-17 04:00:01 UTC
Permalink
Response from SPSS Tech Support was that currently there is no way to
insert SPSS Text object into output via syntax.
JKPeck
2006-10-17 12:22:11 UTC
Permalink
If you have SPSS 15 with programmability installed, this can be done
pretty easily.

Run the following code (it could be included via an INSERT command)
begin program.
import spss
def printcomment(text):
"Insert text into Viewer as a text block"
spss.StartProcedure("Comment")
spss.TextBlock("Comment", text)
spss.EndProcedure()
end program.


Then whenever you want to insert a comment, do something like this:
begin program.
printcomment("""here are some thoughts
about my analysis so far.
It appears that inserting comments works pretty well.""")
end program.

The only condition is that you must have a dataset open when you run
this. The Viewer outline pane will show "Comment" as the outline
entry.

The text in the example was enclosed in triple quotes to allow it to
span multiple lines. The line breaks are preserved in the output.
HTH,
Jon Peck

Something similar can be done with SPSS 14 using the viewer module
Post by Haris
Response from SPSS Tech Support was that currently there is no way to
insert SPSS Text object into output via syntax.
King
2006-10-18 15:37:10 UTC
Permalink
Jon,

Is spss.StartProcedrue a recent addition to the spss module? I can't
get this to work. I get this error message:

AttributeError: 'module' object has no attribute 'StartProcedure'

Thanks,

King
Post by JKPeck
If you have SPSS 15 with programmability installed, this can be done
pretty easily.
Run the following code (it could be included via an INSERT command)
begin program.
import spss
"Insert text into Viewer as a text block"
spss.StartProcedure("Comment")
spss.TextBlock("Comment", text)
spss.EndProcedure()
end program.
begin program.
printcomment("""here are some thoughts
about my analysis so far.
It appears that inserting comments works pretty well.""")
end program.
The only condition is that you must have a dataset open when you run
this. The Viewer outline pane will show "Comment" as the outline
entry.
The text in the example was enclosed in triple quotes to allow it to
span multiple lines. The line breaks are preserved in the output.
HTH,
Jon Peck
Something similar can be done with SPSS 14 using the viewer module
Post by Haris
Response from SPSS Tech Support was that currently there is no way to
insert SPSS Text object into output via syntax.
JKPeck
2006-10-19 12:07:43 UTC
Permalink
Yes, the StartProcedure api is new in SPSS 15. It is part of the
structure that gives programmability code access to the core functions
that standard SPSS procedures use to access and modify data and create
pivot tables and text blocks.

However, with SPSS 14 you can do something almost equivalent using the
view module. Here are docstrings from teh ViewerText class in that
module:

class ViewerText(object):

"""This class provides methods for creating a new text block in the
SPSS Viewer.
These methods will not work in distributed mode, and these items
are not subject to
manipulation by OMS.

This class does not work with SPSS 14.0.1 or 14.0.0 because of a
problem with the
InsertTitle automation method. However, it does work with SPSS
14.0.2."""

def insert(self, viewer, afteritem=None):
"""Insert the text object in the Viewer designated by viewer.
If afteritem is None
the item is inserted after the current item, otherwise, it
indicates the index
of the item after which the item is to be inserted. The index
is automatically
bounded by the number of items in the Viewer.

The item is always inserted at the highest level in the outline
except that if
the chosen location cannot be promoted, the insertion happens
at that level.
The return value is the index of the inserted item."""

-Jon Peck
SPSS
Post by King
Jon,
Is spss.StartProcedrue a recent addition to the spss module? I can't
AttributeError: 'module' object has no attribute 'StartProcedure'
Thanks,
King
Post by JKPeck
If you have SPSS 15 with programmability installed, this can be done
pretty easily.
Run the following code (it could be included via an INSERT command)
begin program.
import spss
"Insert text into Viewer as a text block"
spss.StartProcedure("Comment")
spss.TextBlock("Comment", text)
spss.EndProcedure()
end program.
begin program.
printcomment("""here are some thoughts
about my analysis so far.
It appears that inserting comments works pretty well.""")
end program.
The only condition is that you must have a dataset open when you run
this. The Viewer outline pane will show "Comment" as the outline
entry.
The text in the example was enclosed in triple quotes to allow it to
span multiple lines. The line breaks are preserved in the output.
HTH,
Jon Peck
Something similar can be done with SPSS 14 using the viewer module
Post by Haris
Response from SPSS Tech Support was that currently there is no way to
insert SPSS Text object into output via syntax.
Santiago Sotelo
2021-03-03 03:53:43 UTC
Permalink
Post by Haris
COMMENT outputs as SPSS Log in the output and does not ouput anything
if you SET PRINTBACK to OFF. I am still looking for a way to output
"SPSS Text" not "Log." Anybody know if this is possible or is SPSS
Text only available via pull-down menus?
Thanks
Post by Lawrence
Thanks Richard,
Simple and Great..
For more detail information about COMMENT available in SPSSBASE.pdf.
page number 267.
Thanks,
Lawrence.
ECHO works perfectly fine.

Loading...