Today, Joe Glines, one of our SurveyGizmo survey experts, is guest posting to teach us all a few quick tricks on how to manipulate the SPSS export data we receive from SurveyGizmo.
String Variables to Numeric
While SurveyGizmo allows for changing of variable format in SPSS, sometimes I end up with string variables that really want to be numeric. This can easily be accomplished with a short line of SPSS syntax.
Let’s say you wish to convert the variable named “String_Zip” to a numeric variable entitled “Numeric_zip”. The following code achieves this:
RECODE String_Zip (Convert) INTO Numeric_zip.
While this is simple, the default numeric value in SPSS is a scale variable.
To help remind yourself not to take the “average” of zip code you might want to change the variable level to Nominal. This can be achieved with the following line of syntax:
Variable Level Numeric_Zip (Nominal).
As a reference, below are the other variable levels supported in SPSS
- Variable Level Numeric_Zip (Ordinal)
- Variable Level Numeric_Zip (Scale)
Numeric to String
If you need to convert a numeric value to a string there is one additional step. You must first declare the string variable. The following creates a string variable named String_Zip2 with a width of 5 characters.
Now that you’ve created the variable, you can convert the numeric value to it’s string counterpart.
Dropping unused variables
Want to drop the old numeric variable from the data set? Simply use the match files command with the drop statement.
Match files file=* / DROP Numeric_Zip .
Thank you again, Joe, for teaching us a few quick and easy tricks using SPSS. If you’re out there reading this and would be interested in becoming a SurveyGizmo survey expert, please send us an email at firstname.lastname@example.org and we would be more than happy to start working with you.