Question

I am using the SPSS syntax editor to combine string variables. I know that there will be data in one or zero of the variables for each record, but there will never be data in both variables. This is my code, and the problem is with the first line:

IF (MISSING(ywFamilyPlayers)=1) AND (MISSING(vywFamilyPlayersBoolean)=1) THEN newString=missing.
IF (MISSING(ywFamilyPlayers)=0) newString=VALUELABEL(ywFamilyPlayers).
IF (MISSING(vywFamilyPlayersBoolean)=0) newString=VALUELABEL(vywFamilyPlayersBoolean).
EXECUTE.

I cannot figure out how to assign the system missing value to the string variable when it matches the logical conditions. I can easily assign nonsense text (e.g. "-999" or "") under those conditions, but the system won't treat it as a true missing value when running tests on the data.

Can you help me out? The logic works, but I just cannot figure out how to assign the missing value. I've experimented with many permutations (e.g. $sysmis and MISSING) but to no avail.

Was it helpful?

Solution

Note that there are two types of missingnes in SPSS. Value can be system-missing or user-missing. As far as I know system-missing values are defined only for numeric variables. User-missing values can be defined both for numeric and string variables.

Try MISSING VALUES command to define value "-999" (for example) as user-missing.

IF (MISSING(ywFamilyPlayers)=1) AND (MISSING(vywFamilyPlayersBoolean)=1) newString="-999".
MISSING VALUES newString ("-999").
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top