SPSS Statistics

SPSS Statistics

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

 View Only
Expand all | Collapse all

Is there a way to output data from SPSS showing IDs and corresponding variable values in the same row?

  • 1.  Is there a way to output data from SPSS showing IDs and corresponding variable values in the same row?

    Posted Mon September 28, 2020 02:40 PM

    I would like to create a table with selected data only. I have tried 3 approaches, with issues on each:

    (1) Case summaries

    I am using SPSS>Analyze>Reports>Case Summaries to create an

    output that shows specific variables (listed here as VAR1, VAR2, VAR3)

    by ID (listed as ID). However, I cannot get the output to show the data

    with the ID on the same row as the value for the variables. ID is

    printed one row higher than the data that corresponds to that ID for all

    variables (but all the variables are on the same row). This creates a

    lot of extra work to cut/paste/align the output, which I will have to do

    repeatedly given the nature of the analysis.

    The syntax I am using is:

    SORT CASES BY ID (A). Report /FORMAT=CHWRAP(ON) PREVIEW(ON) CHALIGN(TOP) UNDERSCORE(OFF) ONEBREAKCOLUMN(OFF) CHDSPACE(1)SUMSPACE(0) AUTOMATIC LIST BRKSPACE(0) PAGE(1) MISSING'.' LENGTH(1, 39) ALIGN(CENTER) TSPACE(1) FTSPACE(10) MARGINS(1,185) /TITLE=RIGHT 'Page )PAGE' /VARIABLES VAR1 (VALUES) (RIGHT) (OFFSET(0)) (8) VAR2 (VALUES) (RIGHT) (OFFSET(0)) (8) VAR3 (VALUES) (RIGHT) (OFFSET(0)) (8) /BREAK ID (LABELS) (RIGHT) (OFFSET(0)) (8).

    (2) Export

    I know I could export the entire dataset and then keep the variables of interest, but I need the labels rather than the variable names printed and the export only seems to

    output variable names).

    (3) OMS

    The syntax below does not record the table (just notes, but there is no other option when selecting 'Report').

    * OMS.

    DATASET DECLARE test.

    OMS

    /SELECT TABLES

    /IF COMMANDS=['Summarize'] SUBTYPES=['Case Processing Summary']

    /DESTINATION FORMAT=SAV NUMBERED=TableNumber_

    OUTFILE='test' VIEWER=YES

    /TAG='ID'.

    SORT CASES BY ID (A).

    Report

    /FORMAT=CHWRAP(ON) PREVIEW(ON) CHALIGN(TOP) UNDERSCORE(OFF) ONEBREAKCOLUMN(OFF) CHDSPACE(1)

    SUMSPACE(0) AUTOMATIC LIST BRKSPACE(0) PAGE(1) MISSING'.' LENGTH(1, 39) ALIGN(CENTER) TSPACE(1)

    FTSPACE(10) MARGINS(1,185)

    /TITLE=RIGHT 'Page )PAGE'

    /VARIABLES

    VAR1 (VALUES) (RIGHT) (OFFSET(0)) (8)

    VAR2 (VALUES) (RIGHT) (OFFSET(0)) (8)

    VAR3 (VALUES) (RIGHT) (OFFSET(0)) (8)

    /BREAK ID (LABELS) (RIGHT) (OFFSET(0)) (8).

    omsend tag = ['ID'].

    **Is there a way to output data from SPSS showing IDs and corresponding variable values in the same row?**






    #SPSSStatistics
    #Support
    #SupportMigration


  • 2.  RE: Is there a way to output data from SPSS showing IDs and corresponding variable values in the same row?

    Posted Mon September 28, 2020 03:51 PM

    There are several ways to achieve this. The first creates a text file.

    OMS SELECT TEXT /DESTINATION OUTFILE="C:/TEMP/listing.txt" VIEWER=NO FORMAT=TEXT.

    REPORT /FORMAT LIST/VARIABLES ID EDUC JOBTIME.

    OMSEND.

    The LIST command would create a similar listing but would not show the labels. The WRITE command would create a file but would not have the variable names or labels.

    If you use SUMMARIZE, you could create a pivot table exportable via OMS in whatever format is convenient like this.

    SUMMARIZE

    /TABLES=educ gender BY id

    /FORMAT=VALIDLIST NOCASENUM

    /CELLS=NONE.

    The table type for OMS is 'Report'.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 3.  RE: Is there a way to output data from SPSS showing IDs and corresponding variable values in the same row?

    Posted Mon September 28, 2020 04:07 PM

    Thank you - a relief to see a simple and elegant solution after much troubleshooting.






    #SPSSStatistics
    #Support
    #SupportMigration