Even though I do nearly all my analysis in SPSS, I still prefer to use Excel to graph my data. Unfortunately Excel inverts the legend when graphing. Creating a new variable, or re-coding the old one, is time consuming and errors can creep in. This SPSS macro to invert an ordinal variable with very little work. Saves an amazing amount of time!
It also has a built-in way to filter out too small a sample size.
Using SPSS Macros can save an incredible amount of time. They have a somewhat-steep learning curve but are definitely worth it! This is a short overview of the strength of using a macro to run the descriptives command.
Word of warning, make sure you re-define your macro before calling it. This is an easy step to forget and you can waste a lot of time.
Intro to SPSS Macro Call
Video tutorials demonstrating the usage of the SPSS Macro
https://www.youtube.com/watch?v=5CBm_F3zBOo A lot of online vendor tools provide a data value on a multi-select question however they leave the value missing if the respondent didn’t select it. Most of the analysis I want to do needs to have a zero (or some other value) present in order to calculate the …
Using an SPSS Macro to Open and Save files can be quite a time saver! In my example code & video I demonstrate how to adapt basic SPSS syntax into a macro that automates the process. I also mention this macro which takes the reverse approach (automatically breaks the file into random groups).
The below code it just an example using SPSS macro to open and save text files which will have to be adapted to your needs. Be sure to pay close attention to string variables and the widths you set them at. Generally speaking, set them at double what SPSS assigns them. In reality, there doesn’t seem to be any file-size change when you make them very wide so you also might just default to setting the width to 10X the width (then shrink the column widths with the Var Width command.
In the video I also demonstrate how I used Excel to help write my syntax for looping over all the files as well as merging the files together.
SPSS macro to open and save Text files
DEFINE !OpenSav (In_Path !TOKENS (1) /Out_Path !TOKENS (1) / File_Name !TOKENS (1) )
GET DATA /TYPE=TXT /FILE=!In_Path + !File_Name + ".txt"
/DELCASE=LINE /DELIMITERS="\t" /QUALIFIER='"' /ARRANGEMENT=DELIMITED /FIRSTCASE=2 /IMPORTCASE=ALL /VARIABLES=
DATASET NAME $DataSet WINDOW=FRONT.
Var width All (5) company city (10) .
SAVE OUTFILE=!Out_Path + !File_Name + ".sav" /COMPRESSED.
!OpenSav In_Path="H:\temp\Files\" Out_Path="H:\temp\Out\" File_Name="Rand_1".
Video demonstrating using an SPSS macro to open and save files
While SPSS has many strengths, string manipulation is NOT one of them! Don’t get me wrong, you can manipulate strings however the syntax for doing so is very complex.
If you are still using an older version of SPSS, this macro shows how you can easily remove character(s) from a string both anywhere in the string or at a certain location. Newer versions have a Replace command which can be used to remove unwanted characters.
Video demonstrating SPSS macro to remove characters from strings