ARCHIVED: In SPSS, how do I create binary or dummy variables from an existing string variable?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

When you have an existing string variable and want to create binary, or dummy, variables from it, use the COMPUTE command or RECODE with ELSE. Suppose a string variable internet has three values, Email, WWW, and SFTP:

COMPUTE email = (internet='Email').
COMPUTE www = (internet='WWW').
COMPUTE sftp = (internet='SFTP').
EXECUTE.

SPSS sets 1 to a new variable email if the value of internet is Email, and 0 otherwise. The other dummy variables www and sftp are generated in a similar manner. Also, you may use RECODE as follows:

RECODE internet ('Email'=1) (ELSE=0) INTO email.
RECODE internet ('WWW'=1) (ELSE=0) INTO www.
RECODE internet ('SFTP'=1) (ELSE=0) INTO sftp.
EXECUTE.

If you have questions about using statistical and mathematical software at Indiana University, contact the UITS Research Applications and Deep Learning team.

This is document azcj in the Knowledge Base.
Last modified on 2023-05-09 14:42:22.