This set of notes is for students at Chico State to help build a reference for themselves and future users on how to do tasks in SPSS.
A syntax file is also called a code file or a script file and has a .sps
file type.
This is a list of commands to execute to perform data management or analysis tasks
When using the menu options to complete a task, be sure to specify paste this syntax to get the code when importing data. You can then copy this code into your own .sps
script file for that particular assignment.
.txt
), comma separated values (.csv
) or as Excel files (.xlsx
).spv
file typehttps://libguides.library.kent.edu/SPSS/ImportData
File > Open > Data
File > Read Text Data
Do not copy code from the HTML side. Open the Markdown side instead.
Already have a .sav
file?
The KEEP
statement while importing data only works if you are using GET FILE
and are reading in a pre-existing SPSS data set.
SPSS seems to think everything is nominal.
Be sure to change all quantitative variables to SCALE
.
After your data file has successfully been imported, you'll want to save the the result as an SPSS data file (*.sav format) by following these steps:
File > Save As
. The Save Data As window will appear.Save
.If you choose to only save certain variables in your data set, a KEEP
statement will be generated as part of the SAVE DATA
code. This list of variables can be manually modified later.
A data management file (e.g. dm_addhealth.sps
) is created that when executed
https://libguides.library.kent.edu/SPSS/data-management
SPSS seems to save values as Nominal as default.
You can change the data type by doing:
There are two ways to recode.
RECODE varname (list of recodes)
overwrites the existing variable.
I recommend you use RECODE varname (list of recodes) INTO newvarname
to recode the raw variable into a new one. This way if you mess up on the recode (which will happen eventually) you can fix your code and try again without having to read the entire raw data set in again.
Important note: If you are using RECODE INTO want to change only one value (like a 99
to SYSMIS
), you have to COPY the remaining values into the new variable.
EXAMPLES:
Change values and save copy into new variable
Recoding multiple variables
Confirm changes were done correctly to recode BIO_SEX
into FEMALE
VARIABLE LABELS 'FEMALE'.
Really good walk through for data exploration
https://libguides.library.kent.edu/SPSS/Explore
Frequency Tables
https://libguides.library.kent.edu/SPSS/FrequenciesCategorical
Analyze --> Descriptive Statistics -> Frequencies
Bar Charts
Analyze --> Descriptive Statistics -> Frequencies --> Charts (bar chart)
If you want a barchart with proportions, change FREQ
to PERCENT
.
Analyze -> Descriptive Statistics -> Descriptives
To get median and quantiles you have to use FREQUENCIES, even though a freq table is not appropriate for continuous data.
NTILES=4
gives you the quartiles.Plots
You may get a message saying "measurement levels shoudl be set properly for each variable". You should pay attention to this, but you can also hit "don't show again" and "OK" to continue.
Summary Statistics
Analyze -->
Plots
Summary Statistics
How to calculate summary measures listed above separately for each group.
Plots
Summary Statistics
Plots
Scatterplot: graph --> Scatter/Dot
Add trend lines
http://www.unige.ch/ses/sococ/cl/spss/eda/smoothing1.html
**To run the two means sample T - Test
Go to:
analyse -> compare means -> Independent samples T- Test
Reading the SPSS two sample means T - Test
GLM with categorical variable
1.Point and click Analize -> Generalized Linear Models -> Univariate
2. Choose Type of model, Response(put in dependent variable),Predictors(put variables into factors and covariates), Model (move variables over Make sure that the :build Term(s)type is "Main Effects")
3. Options -> Check "Parameter Estimates"
4. OK/Run
Sort cases by stratification variable (jtype
)
sort cases by jtype.
Split file by the stratification variable (jtype
)
split file by jtype.
Calculate summary statistics within each strata.
Example here is correlation of salary
with whours
.
correlations salary with whours.
Turn off file splitting
split file off.