SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  Set page title with a variable?

    Posted Thu September 14, 2023 08:44 AM

    I'm hoping to find a way in SPSS Statistics syntax to set the output page title with the value of a variable.

    I know the "normal" way to set the page title is:
    TITLE "This is my new page title".

    The context and full question is I'd like to use the DO REPEAT construct and change the title within that, as in:

    DO REPEAT TitleTextVar = Title1, Title2/
        OtherVar = x1, x2.

    TITLE TitleTextVar.
    COMPUTE OtherVar = 0.
    .
    .
    .
    END REPEAT.

    This doesn't seem to work.  DO REPEAT seems to ignore the TITLE command and just sets the page title to "TitleTextVar".

    I know that I can accomplish my goal by not using DO REPEAT and just having a very long syntax file where I manually enter the title text, but the DO REPEAT is such a nice elegant solution to accomplish everything else I want to do.

    Thanks for any ideas.



    ------------------------------
    Urban Landreman
    ------------------------------


  • 2.  RE: Set page title with a variable?

    Posted Thu September 14, 2023 09:15 AM
    Unfortunately, DO REPEAT only honors the following commands (from the CSR).
    Data transformations: COMPUTE, RECODE, IF, COUNT, and SELECT IF
    • Data declarations: VECTOR, STRING, NUMERIC, and LEAVE
    • Data definition: DATA LIST, MISSING VALUES (but not VARIABLE LABELS or VALUE LABELS)
    • Loop structure commands: LOOP, END LOOP, and BREAK
    • Do-if structure commands: DO IF, ELSE IF, ELSE, and END IF
    • Print and write commands: PRINT, PRINT EJECT, PRINT SPACE, and WRITE
    • Format commands: PRINT FORMATS, WRITE FORMATS, and FORMATS

    It would be possible to accomplish what you want with a small block of Python code that iterates over the variable lists, setting the title and running syntax at each iteration.  I can send you an example if you want to go that route.

    --





  • 3.  RE: Set page title with a variable?

    Posted Thu September 14, 2023 10:25 AM

    Thanks, Jon, for your offer to send me a Python snippet.
    I figured that a Python loop might be able to generate the required SPSS Statistics syntax.

    If you could send me the example, I can take it from there.

    Urban



    ------------------------------
    Urban Landreman
    ------------------------------