Every so often I point out to a client who exclusively uses menus in SPSS that they can (and should) hit the Paste button instead of OK. Many times, the client never realized it was there.
I am here today to tell you that it is there, and it is wonderful. For a few reasons.
When you use the menus in SPSS, you’re really taking a shortcut. You’re telling SPSS which syntax commands, along with which options, you want to run.
Clicking OK at the end of a dialog box will run the menu options you just picked. You may never see the underlying commands that SPSS just ran.
If instead you hit Paste, those command won’t automatically be run, but will instead the code to run those commands will be copied into the Syntax window.
You can then, through the syntax window, run all or part of the syntax commands.
Having all your commands in the Syntax Window Saves so Much Time
I’ve already written about reasons to use syntax, so I won’t repeat myself. I’ll just mention that most of those are about saving time.
Just last week I met with a client who is nearly done with her dissertation.
She mentioned that she had started using syntax just recently, toward the end of her project. She wished she’d started earlier because it was so much easier and faster than running through the menus.
But she didn’t know about the Paste button. She’d been running each command, then copying the syntax out of her output into the syntax window.
You don’t have to remember every little command option
I was recently at a one-day regional statistics conference and attended an introductory talk about using R. It was less than an hour, so was really just a demonstration.
As you probably know, I am not a regular R user, but have some experience with it. So I was able to follow along pretty easily.
What struck me most was not that R was difficult (as seems to be the general perception), but that it could be very frustrating if you don’t use it on a regular basis.
It’s pretty logical, and the commands make sense. With some good basic training, it looks quite doable. What struck me though, is what an advantage the Paste button is in SPSS.
With the Paste button you don’t have to remember the exact syntax to get a command to run exactly the way you want it.
Need to run 20 different crosstabs but don’t remember the exact option to get row percentages? Just run one through the menus, and hit paste. Copy and paste it 19 times, then change the relevant variable names. Easy-peasy.
(Now, to be fair to R, there very well may be a way to do the same thing. The talk demonstrated quite clearly that using a plugin like R-Studio would make life much easier. I know there are a number of GUIs for R. If you know of one that does allows you to paste the code, please share in the comments.
And secondly, savvy programmers always save their code and edit it for other programs).
One way I like to use the Paste command to save time
If you’ve ever analyzed a large data set using the menus, you already know how tedious it can be to find the variables you need in the long list of variables. This is especially true when the variable names are all very similar.
It drives me nuts, personally.
So in my impatience, I’ve realized how to use Paste to my advantage. Let’s say I want to run a crosstab on two variables whose names I know, but I can’t find them in the list of variables.
But I also don’t remember the exact syntax commands.
I run a crosstab through the menus and pick any two variables. Paste the syntax.
Now I edit my syntax in the syntax window using the variable names I can remember without having to find them in a long list. Then I run it.
If you’d like to learn more about how to use SPSS, both in menus and syntax, take a look at our online workshop Introduction to Data Analysis with SPSS.
Bruce Weaver says
I have a (possibly picky) comment regarding this paragraph.
“Need to run 20 different crosstabs but don’t remember the exact option to get row percentages? Just run one through the menus, and hit paste. Copy and paste it 19 times, then change the relevant variable names. Easy-peasy.”
Rather copying the entire command 19 times (and editing), I would copy the TABLES sub-command only and paste *it* 19 times, and then edit the variable names. E.g.,
CROSSTABS
/TABLES=r1 BY c1
/TABLES=r2 BY c2
/TABLES=r3 BY c3
/TABLES=r4 BY c4
/TABLES=r5 BY c5
etc.
/TABLES=r20 BY c20
/FORMAT=AVALUE TABLES
/CELLS=COUNT ROW
/COUNT ROUND CELL.
It may be that there is a limit on the number of TABLE sub-commands one can include. If so, then multiple CROSSTABS commands might be needed.
Cheers,
Bruce
Karen Grace-Martin says
Fair enough, Bruce. 🙂 That is probably the more efficient way to do it.
Glenna Schluck says
R Markdown is great and integrates with R-Studio. It allows you to write your text and your code all in the same document. Once you look up the exact syntax for what you need, you can copy/paste as needed. Also, the output file can be saved in a variety of formats (pdf, html, docx, etc) with all of your descriptions, code (or not), and output (or not) as you choose. I’ve only recently begun using it but it is much more user friendly than trying to edit/annotate SPSS output. https://rmarkdown.rstudio.com/
Jim W says
Thanks for the article and the validation of running syntax based on some pasting. One thing I would add is that you do not necessarily have to remember to paste either. I often run “adhoc” syntax and think I do not need to save it only to find out later I do. You can get all the syntax you have ever run in the journal file that is by default saved by SPSS. I do not use this very often but for the person you mentioned who did not know about pasting syntax from the GUI they can always go pack to their journal file to get the syntax your forgot (or did not know) to save.
Karen Grace-Martin says
Hi Jim,
Agree! The journal files is a great secret resource. It has saved me before, but my journal is HUGE. But others may find theirs is not so big that it’s easier to find the syntax they’re looking for.
Dhritiman Chakrabarti says
I would like to add to the topic of syntax editing with the use of “Concatenate” function of Microsoft Excel. If you need to run the same syntax for a number of variables, it is quite tedious to copy and paste each variable separately. Since most of the syntax other than the variable name is invariant, I just create a column of the same in an excel spreadsheet and in the adjoining column, I paste the variable name which we require and join the text of two columns using concatenate function of excel.
This gives us a column of syntax of multiple variables to be directly pasted into SPSS and get the results.
I use the same method for R too, if I am running multiple models. In R, looping might allow you to do the same, but I am not very familiar with it as of now.
Michael Moore says
Hi, Karen.
Thanks for this great article, as well as “Non-parametric ANOVA in SPSS”. Actually, my question concerns both topics.
Do you know of any syntax commands that will allow me to adjust the p-value (Bonferroni adjustment) for Mann-Whitney post-hoc tests, after a Kruskal-Wallis test has indicated a significant difference in ranks? My version of SPSS doesn’t give me the option to adjust p-values on the menus of non-parametric tests.
Any help will be much appreciated. Thanks!
Karen says
Hi Michael,
You don’t adjust the p-value with Bonferroni, you adjust alpha.
So nothing to do in SPSS. Just take the p-value you get, and state the new value of alpha/k (where k is the number of tests) that you’re comparing that p to.
Michael Moore says
Thanks, Karen!
Richard says
Hi,
R-Studio is an IDE and not a plug-in. R-Commander (you could call it a plug-in) allows for clicking menues but actually generates R syntax to be copy and pasted http://www.rcommander.com/
Same goes for JGR http://www.rforge.net/JGR/ and I guess also for RKWard (Linux only) http://userbase.kde.org/RKWard