How can I automatically display the variable label as title in spss syntax

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I automatically display the variable label as title in spss syntax

Kevin Wong-2
Hello,everybody:
   I always use the spss syntax to create a lot of tables in my work,but I
am worried about a problem about the titles of the tables.For example:
  * Basic Tables.
TABLES
  /FORMAT BLANK MISSING('.')
  /TABLES income
  BY  (STATISTICS)
  /TITLE  'income'.

Only the constant character string can be specified in the title
subcommand ,but I hope to  automatically display the variable label as
title in spss syntax ,such as:

 * Basic Tables.
TABLES
  /FORMAT BLANK MISSING('.')
  /TABLES income
  BY  (STATISTICS)
  /TITLE  var label.

When executed,a warning occurs.

So can you fix this issue in some way?
Help me!
Reply | Threaded
Open this post in threaded view
|

Chart editor problems

Ragnar Hanas
Hello,
I have been using SPSS for > 10 years but I am new to this list and would
appreciate some help. I just stepped up from 11.5 to 14 and I am having
problems with the chart editor It doesnt´t behave the same way I am used to
from 11.5 and the manual does not address help:

1) I have to click and double-click many times to be able to edit the text
on the x and y-axis. Then after closing and reopening chart editor this text
is locked. Other functions in Chart Editor seem to work OK. I tried editing
the chart on another computer with v. 14 installed but it didn´t work - same
problem. Is this a known bug - is there a fix available?

2) With 11.5 I just copied the chart into my vector graphic program (Corel
Draw) and edited it there. Now the paste special option of metafile is not
available. When exporting to .eps file the text on the chart comes out as
curves although I have checked for it to remain as text. How do you others
display your graphics? Just copy them into the Word or Powerpoint document
as bitmaps without editing?

Thanks and kind regards,
Ragnar Hanas, MD
Uddevalla Hospital, Sweden
Reply | Threaded
Open this post in threaded view
|

Re: How can I automatically display the variable label as title in spss syntax

Ken Chui
In reply to this post by Kevin Wong-2
Hello, you may change it into a small macro:

* Define the macro name as "vartitle" with a token as "inlist".
DEFINE !vartitle (inlist = !ENCLOSE("(",")")).
!DO !I !IN (!inlist).
TABLES
  /FORMAT BLANK MISSING('.')
  /TABLES !I
  BY  (STATISTICS)
  /TITLE !QUOTE(!I) .
!DOEND .
!ENDDEFINE .

* Evoke the macro with the variable of your choice.
!vartitle inlist = (income).
EXE .

<><><><><>
If you have multiple varialbe, just expand the "inlist", e.g.
!vartitle inlist = (income gender education ethnicity).
EXE.

Then you should be able to get the tables.

Hope this helps.

Ken

On Wed, 13 Jun 2007 02:57:20 -0400, Kevin Wong <[hidden email]> wrote:

>Hello,everybody:
>   I always use the spss syntax to create a lot of tables in my work,but I
>am worried about a problem about the titles of the tables.For example:
>  * Basic Tables.
>TABLES
>  /FORMAT BLANK MISSING('.')
>  /TABLES income
>  BY  (STATISTICS)
>  /TITLE  'income'.
>
>Only the constant character string can be specified in the title
>subcommand ,but I hope to  automatically display the variable label as
>title in spss syntax ,such as:
>
> * Basic Tables.
>TABLES
>  /FORMAT BLANK MISSING('.')
>  /TABLES income
>  BY  (STATISTICS)
>  /TITLE  var label.
>
>When executed,a warning occurs.
>
>So can you fix this issue in some way?
>Help me!
Reply | Threaded
Open this post in threaded view
|

Re: How can I automatically display the variable label as title in spss syntax

Peck, Jon
Tables and Ctables do not give you a built-in way to title a title with the variable label since in general there will be several variables in a single table request.  However, this is easy to do if you can use programmability, introduced in SPSS 14.  Here is a simple example.

First it creates a Python dictionary for the specified variables (this example uses the cars.sav dataset).

Then it loops through the specified variables and submits a TABLES command on the variable name with the variable label as the title.  The code substitutes the variable name in the title if there is no variable label.

HTH

begin program.
import spss, spssaux

vardict = spssaux.VariableDict("year origin cylinder")

for var in vardict:
  varlabel = var.VariableLabel
  if varlabel == "":
    varlabel = var.VariableName
  spss.Submit("""TABLES /TABLE %s BY (STATISTICS) /TITLE "%s".""" % (var.VariableName, varlabel))
end program.

Regards,
Jon Peck


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ken Chui
Sent: Wednesday, June 13, 2007 8:37 PM
To: [hidden email]
Subject: Re: [SPSSX-L] How can I automatically display the variable label as title in spss syntax

Hello, you may change it into a small macro:

* Define the macro name as "vartitle" with a token as "inlist".
DEFINE !vartitle (inlist = !ENCLOSE("(",")")).
!DO !I !IN (!inlist).
TABLES
  /FORMAT BLANK MISSING('.')
  /TABLES !I
  BY  (STATISTICS)
  /TITLE !QUOTE(!I) .
!DOEND .
!ENDDEFINE .

* Evoke the macro with the variable of your choice.
!vartitle inlist = (income).
EXE .

<><><><><>
If you have multiple varialbe, just expand the "inlist", e.g.
!vartitle inlist = (income gender education ethnicity).
EXE.

Then you should be able to get the tables.

Hope this helps.

Ken

On Wed, 13 Jun 2007 02:57:20 -0400, Kevin Wong <[hidden email]> wrote:

>Hello,everybody:
>   I always use the spss syntax to create a lot of tables in my work,but I
>am worried about a problem about the titles of the tables.For example:
>  * Basic Tables.
>TABLES
>  /FORMAT BLANK MISSING('.')
>  /TABLES income
>  BY  (STATISTICS)
>  /TITLE  'income'.
>
>Only the constant character string can be specified in the title
>subcommand ,but I hope to  automatically display the variable label as
>title in spss syntax ,such as:
>
> * Basic Tables.
>TABLES
>  /FORMAT BLANK MISSING('.')
>  /TABLES income
>  BY  (STATISTICS)
>  /TITLE  var label.
>
>When executed,a warning occurs.
>
>So can you fix this issue in some way?
>Help me!