SPSS Tutorials

BASICS REGRESSION T-TEST CHI-SQUARE TEST ANOVA

Changing Variable Properties 3 – Type

SPSS offers several ways to change a variable's type. This tutorial will walk you through some examples.

SPSS Variable Type - Why Change it in the First Place?

Changing Variable Type in SPSS

SPSS Alter Type Syntax Examples

(The test data used by the syntax below are found here.)

*1. Convert "birthday" to string.

alter type birthday(a10).

*2. Convert back to numeric variable with date format.

alter type birthday(edate10).

SPSS String and Numeric Functions

SPSS String and Numeric Syntax Examples

(The test data used by the syntax below are found here.)

*1. String command for declaring new string variable.

string str_q1(a1).

*2. Fill new string variable with values.

compute str_q1 = string(q1,f1)./* String function.
exe.

*3. Convert new string variable back into a (new) numeric variable.

compute num_q1 = numeric(str_q1,f1).
exe.

*4. Remove both new variables after exercise.

delete variables str_q1 num_q1.

SPSS Autorecode Command and Valuelabels Function

SPSS Autorecode and Valuelabels Syntax Examples

(The test data used by the syntax below are found here.)

*1. Convert string to (new) numeric variable with autorecode command.

autorecode name
/into num_name.

*2. Declare new string variable with string command.

string str_name(a10).

*3. Fill string variable with value labels of (numeric) variable.

compute str_name = valuelabels(num_name).
exe.

*4. Delete both variables at end of exercise.

delete variables num_name to str_name.

Previous tutorial: Changing Variable Properties 2 – Names

Next tutorial: Changing Variable Properties 4 – Width and Decimals

Let me know what you think!

*Required field. Your comment will show up after approval from a moderator.

This tutorial has 9 comments