A common problem with SPSS data files are unlabeled variables with huge names. These cause several problems:
- editing and analyzing your data takes too much time and effort;
- your syntax becomes unreadable and unmanageable;
- your output looks terrible.
The way to go in this case is setting such variable names as labels. Next, set nice and short variable names. How? I'll show a quick way to do so trials.sav, part of which is shown below.
1. Copy-Paste Variable Names into Googlesheet
A nice and easy way to fix the problem starts with opening a Googlesheet. Next:
- copy the variable names from variable view into columns A and C of your sheet;
- replace the underscore with a space for column C;
- fill columns B and D with a double quote;
The result is in this spreadsheet.
2. Copy-Paste Googlesheet into SPSS Syntax
Now copy-paste all contents of our Googlesheet into an empty SPSS syntax window. Replace double quotes followed by a tab by just double quotes as shown below.
VARIABLE LABELS in front of all syntax and a period at the end. This results in the syntax below. Running it sets nice variable labels for all variables with long names.
3. Move Variable Names into Labels Syntax
Trial_1_Reaction_Time_Milliseconds "Trial 1 Reaction Time Milliseconds "
Trial_2_Answer "Trial 2 Answer "
Trial_2_Reaction_Time_Milliseconds "Trial 2 Reaction Time Milliseconds " /*... AND SO ON UNTIL ...*/
Trial_20_Answer "Trial 20 Answer "
Trial_20_Reaction_Time_Milliseconds "Trial 20 Reaction Time Milliseconds ".
4. Shorten Variable Names
Now that we set our excessively long variable names as variable labels, we can safely shorten our variable names with a single line like rename variables (Trial_1_Answer to Trial_20_Reaction_Time_Milliseconds = v1 to v40). The final result is shown below.
The entire operation took some 3 minutes. However, it'll save a lot of time and headaches when we start editing and analyzing these data. On top of that, my newly set variable labels look great in output tables!
For keeping things nicely organized, you could run the VARIABLE LABELS syntax with INSERT. This command runs an entire syntax file without having to open it.
Second, Googlesheets allow you to create many lines of errorless syntax fast. In this example, we set some variable labels but you could run a lot of scatterplots in a similar way.
A better alternative for such tasks, however, is Python for SPSS. It allows you to do much more -and way faster. If you can find the time, try to learn some.
Thanks for reading!