Search code examples
spss

Part of the data is not displayed fully in spss


I want to create a new string variable (Education) which will contain data from other string variables (Listofuniversities, Listofschools).

The problem is that the data in the variable Education is not displayed fully. It is displayed like this:

Education
TU
Gymna
TL

My original dataset look like this:

Listofuniversities   Listofschools
TU                   
                     Gymnasium van der Ort
TEU                  
                     Gymnasium van der Ort
TU                   
                     Gymnasium van der Art
TL                   
                     Gymnasium van der Art

This is the syntax that I have written.

STRING Education (A8).
RECODE Listofuniversities ('TU'='TU') ('TEU'='TEU') ('TL'='TL') INTO Education.
EXECUTE.
RECODE Listofschools ("Gymnasium van der Ort" = "Gymnasium van der Ort") into Education. 
VARIABLE WIDTH Education(20).
EXECUTE.

Solution

  • Your data looks as if there are two fields "Listofuniversities" and "Listofschools"; both string fields. It seems like the two fields are independent of one another. When there is a non-blank value in one, there is a blank in the other. Was this intended? If not, I'd look at how you read the data into the program.

    Your first command creates a string field 8 characters wide (Education). The values you try to put into "Education" (from "Listofschools" at least) are clearly more than 8 characters wide. So it is appropriate to define "Education" as a wider field. e.g. STRING Education (A50).

    If your intent is to consolidate these values across records:

    STRING Education (A50).
    DO IF (Listofschools=" ").
    COMPUTE Education = RTRIM(LTRIM(ListofUniversities)).
    ELSE.
    COMPUTE Education = RTRIM(LTRIM(Listofschools)).
    END IF.
    EXECUTE.