
 Area under the
curve using Trapezoidal Integration.SPS
 Incremental Area under the curve.SPS

Top 

 Example of bat file
running an sps file
 Run syntax from batch
file or command line.SPS

Top 

 Completely Randomized Designs.SPS (equal or unequal n per treatment)
 Random
assignment of units to experimental treatments.SPS This is for Randomized Block Designs (Simple & Generalized)
and Completely Randomized Designs (equal n per treatment)


Tip: any time you use random numbers and need to be able to reproduce
your results, use "SET SEED=number." at the beginning of your syntax
where 'number' is any 'random number' you come up with. One option is to use the current
date & time (e.g. "SET SEED=1120722." if it is 7h22 on Nov 20th)

 Bootstrap confidence interval for the variance of a
variable.sps
 Bootstrap confidence
interval for Cronbach alpha.SPS
 Bootstrap crosstab.SPS
 Bootstrap ordinary least square
(OSL) estimators.SPS
 Bootstrap the mean and
median.SPS
 Generating multinominal random
variables.SPS(AnswerNet)
 Generating
multivariate hypergeometric random variables.SPS
(AnswerNet)
 Generating
multivariate normal variables with a specific covariance matrix (AnswerNet)
 Generate random triad
numbers.SPS
 Get random sample
of various size then calculate statistics.SPS (Compare means of n samples of size s1
s2 ... sn ...)
 Get various
random samples of same size calculate statistics.SPS (Compare means
of n1 n2 ... nn samples of size s)
 Sampling distribution
of the correlation between 2 variables.SPS
Bootstrapping using OMS (this requires v12)
 oms_bootstrapping.sps

Top 

 Bar
charts for school types by sex where percentages of each sex add up to 100 percent.SPS
 Blank bar for unselected
category.SPS (from AnswerNet)
 Blank bar for
unselected category (generalized).SPS (note however that to show
empty categories in CTABLES is trivial. All that is required is to
specify EMPTY=INCLUDE in the /Categories subcommand)
 Compare
(superimpose) two histograms.SPS could also use a population
pyramid (see IGRAPH section below for an example)
 Count outliers.SPS (show number of
outliers in a boxplot)
 Do
bar charts excluding categories with small number of cases.SPS
This macro is fully commented
here.
Newbie's who do not know how to use a macro should read
this explanation.
 Do many
histograms with the same axis boundaries.SPS (this demonstrates how
the use of the macro Dograph.sps
and template Dograph.sct
to produce many graphs with the same x and y scale.
 Graph
cumulative percentage retired at attained age by categorical variable.SPS
 Graph cumulative
percent on X axix.SPS
 Graph survey question.SPS
 Histogram
with percent on y axis instead of numbers.SPS
 Identify your own data
in the chart.SPS
 Identify your own data
in the chart version2.SPS This is a generalization
of the above syntax. It uses the following chart template
Identify Your Own Data.sct
(rightclick on this template and select save target)
 Print current date in
chart title.SPS
 Print current date
and time in chart title.SPS (Same technique can be used with Tables)
 Print
histogram or bar chart depending on data.SPS(A good macro example)
 Print school
names as part of graph titles.SPS
 Show mean values in line
graph.SPS
 Show 2 categories on
same histogram.SPS
 ZIPF law and graph.SPS
Tables
 Construct a table
"manually" in the data editor.SPS(A good example of data
restructuration)
 Construct
a table "manually" example no 2.SPS
(non trivial
code...)
 Find
population frequency when multiple response with long strings.SPS
 List variables in
frequency table by order of medians.SPS
 Print actual name
group and id in heading of each listing.SPS
 Print mean plus minus
standard deviation in Table.sps
 Put 4 variables in the
same frequency table.SPS
 Show empty category in
tables.SPS (from AnswerNet) Note: This is trivial with CTABLE)
 Show empty
categories in tables (second method).SPS
 Show mean values.SPS
 Show number of
valid cases in table footnote.SPS
 Table where list of
variables is generated by macro.SPS (Illustrates the !IF ...!ELSE
... !IFEND macro command)

CTABLES
 Get statistics for grouping of variables.SPS
 Sort categories by decreasing count but with Others as last one.SPS
 Using Macros and CTABLE.SPS

Top 

 Cluster
analysis using similarity proximity (count) data as input.SPS
 Save centers of
Hierarchical cluster analysis as initial value of Kmeans.SPS

Top 

 All combinations of 3
numbers out of n.SPS (see "Find all Combinations .." below
for a generalization)
 All combinations of 3
letters out of n.SPS (with replacement)
 Calculate
interaction terms between 2 categorical variables.SPS (within a
regression context)
 Create
a new variable for each combination of 2 variables.SPS
 Find all
combinations of 1 up to n items out of m items.SPS (high
power stuff!)
 Find all
combinations of n items out of m items.SPS (high power stuff!)
 Find all
permutations of integers 1 to n.SPS Maximum value of n is 7.
Combined with recode, this can find permutations of any strings or numbers.
 Generate orders for
block of trials.SPS
 Get all
possible crossproducts of pairs of variables.SPS (contains a fair
amount of comments)

Top 

 Automatically compute sample weights
to approximate population.SPS
 BoxCoxTransformation.SPS
To transform var1 using each of the 31 values of lambda that are
between 2 and 1 (increments of 0.1).
 Count number of distinct
values across 400 variables.SPS
 Compute percentage of patients having each fracture category.SPS
 Compute z = x / max( y) where
max( y) is over all cases.SPS (it is sometimes
preferable to use this macro technique)
 Compute distances between 2 points on earth.SPS
(with thanks to Simon Freidin)
 Compute
average of m variables where m is a variable in the data file.SPS
 Create a new variable equal to mean of an other variable.SPS
 Find the cubic root.SPS
 Reverse the digits on an integer.SPS
 Weight data based on 2 or more vars.SPS
With thanks to João Duarte!

Top 

 Apparent problem with concat.SPS
Newbies should take a look at this example.
 Combine a string variable and a numeric variable.SPS
 Concatenate.SPS (new
string equals concatenation of values in second variable)
 Concatenate content
of cases with same id.SPS
 Concatenate
numbers.SPS
 Concatenate 22 variables.SPS
 Convert first letter of each word to upper
case.SPS (Thanks to A. Paul Beaulne for sending me this code)
 Create an id using name and dob.SPS
 Normalise alpha.sps
(Capitalise the first letter of each word, use lower case for the other letters)
 Normalize string.SPS
(delete spaces at beginning, remove period at end, capitalize all letters)
 Remove initial from name.SPS
 Remove period from string.SPS(can
be modified to remove any other characters)
 Reorganize names.SPS (place family name at the beginning of the sting)
 Transform ascii codes
into characters.SPS

Top 

 Reduce size of columns
in data editor.SPS
 Right align strings in data editor.SPS

Top 

 Perform tests on ssn.SPS
 Validate likert
and continuous values.SPS


 Add 60 days to a date
then find end of that month.SPS
 Add leading zeros to a string date.SPS
 Ages are in nnH nnD nnM and nnA.SPS
 Break down
number of days in hospital by calendar month.SPS
 Calculate age.SPS
 Calculate time differences to milliseconds.SPS
 Calculate mean date and
standard deviation in days.SPS
 Calculate nb of days within the eligibility period.SPS
 Caculate number of minutes between 2 timestamps (crossover midnight).SPS
 Calculate number of
months between 2 dates.SPS
 Calculate
waiting time when time is coded in hh min.SPS
 Compute number of
weekdays between 2 dates.SPS
 Compute
number of weekdays excluding public holidays.SPS
 Compute sleep time.SPS
 Convert basis.SPS
 Convert strings into numbers.SPS
(variable contains age in either of the following format "7
Y" for 7 years, "3m" for 3 months, "28D" for
28 days. Need to convert these to years.)
 Convert
string formated as hhmmss into numeric time variable.SPS
(thanks to Jim Marks)
 Convert string 01jan1992 to a date variable.SPS
 Convert string 19970822 into a date variable.SPS
 Convert string into date and time variables.SPS
 Convert
string "20060428 18:20:01" to datetime format.sps
 Convert string to
date and select cases which fall during the weekend.SPS
 Convert string
"04Apri03" to a date variable.SPS
 Date plus 3 months.SPS
 Dates appear as asterix on
chart.SPS (solution)
 Extract
time portion from string variable containing date and time.SPS
 From AM PM to military time.SPS
 Importing from
excel (convert days into dates).SPS
 Keep
time portion of date when creating Tab delimited file.SPS
 Make variable equal to
current date.SPS
 Number of
consecutive 30 minutes of hypoxia.SPS
 Print current date as
part of graph title.SPS
 Print date and time
before a procedure.SPS
 Print day name along with date.SPS
 Read time stamp.SPS
 Save data file with current date as part of name.SPS
 Select a range of dates.SPS
 Time an SPSS procedure.SPS

Top 

 Add variables containing lower
and upper CI for mean.SPS
 Bayes estimates for proportions and their CI.SPS
with thanks to Evgeny Ivashkevich (this also calculates Confidence
Intervals for a category not present in the sample)
 Calculate Chisquare significance
given q and df.SPS
 Calculate 95 percent
confidence interval for the median.SPS
(thanks to Marta
GarciaGranero)
 Calculate McNemar ChiSquare test.SPS(thanks to Marta)
 Hodges Lehmann
Confidence Interval for Median difference.SPS
(thanks to Marta
GarciaGranero)
 Exact
confidence limits for a binomial parameter.sps
 Goodness of fit test for Poisson Distribution.SPS
(thanks to Marta GarciaGranero)
 Normalization
of raw scores (with thanks to Valentim R. Alferes)
 Proportion tests and confidence
intervals.SPS (thanks to Gwilym Pryce) This includes largesample
 significance test for a single population proportion  confidence interval for a single population proportion  significance test for two population proportions  confidence intervals for comparing two population proportions  Testing linear
constraints in MR.SPS with thanks to Johannes Naumann. This macro
tests General Linear hypothesis of the type cb=d, where b is a vector
of regression coefficients and c is a matrix of linear constraints.
 Univariate and multivariate
tests of skew and kurtosis (a link to Lawrence T. Decarlo's SPSS
macro). The same site also contains
 SPSS macro for Mardia's multivariate skew  SPSS programs for signal detection models expressed as generalized linear models Fitting distributions
 Fitting models with overdispersion or 'extraPoisson' variation.SPS

Top 

 Export all tables in word.SPS
(see Sample Scripts for an automated
solution)
 Export
data and value labels to excel.SPS
 Export content of data editor to
a specified sheet of an existing Excel workbook.SPS
 Export from SPSS to ACCESS.SPS
 Export from SPSS to
ACCESS (method2).SPS
 Export more than 256 vars to Excel.SPS
 Export some SPSS vars to many sheets of Excel workbook.SPS
 Import from ACCESS or
LotusNotes.SPS (no DSN needed: this is very handy. Thanks to Tom
Dierickx)
 Writing back
an SPSS 10 file to an ODBC database.SPS (from AnswerNet)

Top 

 Determining the number of
components using parallel analysis and Velicer's MAP test (a link to
Brian P. O'Connor's site)
 Factor analysis with Spearman
correlation through a matrix.SPS

Top 

 Exclude
"outliers" from analysis.SPS (where outliers are defined
as cases outside Mean +/ 2 SD)
 Flag cases
where a given string variable contains a given word.SPS
 Flag
cases where any of a list of variables have same value.SPS
 Flag
cases where salary is in top 95 percentile.SPS
 Flag
cases meeting a certain condition as well as preceding and following case for
the same person.SPS
 Flag first and last
dates (within each ID).SPS
 Keep only duplicate
cases.SPS
 Print
frequency table of the n most (less) frequent items.SPS
 Select
patients where drug1 was given before drug2.SPS
 Select
cases where same letter appears twice in string.SPS
 Sophisticated
search in string variable.SPS (data were scanned, portion of strings
include letters (eg B) instead of numbers (eg 8); this syntax flags the errors)

Top 

 Clustered bars
with percent based on total in cluster.SPS
 Example of surface plot.SPS
 Graphing an arbitrary function.SPS
 Graph showing
interaction in multiple regression.SPS
 How to speed up IGRAPH.SPS (A similar approach could be used for other type of
graphs)
 Population pyramids.SPS
 Produce long
IGRAPHs.SPS
 Separate box plot graph
for each category value.SPS (syntax can be adapted to any other type
of graph)

Top 

 Syntax for item analysis.SPS
This is based on SPSS's
White Paper on Item Analysis and on this Exercise
data file.
 Syntax
For Item Analysis V6.sps This is a much improved version
of the above. It is fully automated and has been developed and
tested using SPSS 15.



 Add
(or replace) a character at the beginning of each var names.SPS
 Add
'_99' at the end of every variable names.SPS
 Apply lab1 as
value label to var1 by syntax.sps
 Assign same
label to many variables.SPS
 Assign value
labels to a vector.SPS
 Assign
variable and value labels of a given variable to other variables.SPS
 Automatically
rename variables.SPS
 Auto
variable renaming or copying.SPS
 Change
case of Var Labels and/or Value Labels.SPS with thanks to Simon
Freidin
 Change format of
600 variables.SPS
 Convert variable
format.SPS (see also the
following tutorial. If you are not
familiar with macros, see this macro
tutorial for newbies).
 Create dummy
variables.SPS (also called indicator or binary variables)
 Create dummy
variables (AnswerNet).SPS
 Create
new variable equal to number of occurrences of var1.SPS
 Define a global
variable.SPS (this is a useful programming
technique)
 Define variable
label by Macro.SPS
 Delete all variable
labels of a given sav file.SPS
 DeleteListOfVariableNames But Some May Not Exist.SPS
 Delete variables with all values equal to zero.SPS
 Delete or
reorder variable names (data fields).SPS
 Delete many
variable labels.SPS
 Group
data and define corresponding value labels.sps
 Define list of
variables between two variables.SPS (a macro Gem)
 Match label file
with data file.SPS
 Print
variable labels and value labels in FREQ Tables.SPS
 Read
ASCII data variable name, value and value labels.SPS
 Recode
variables var1 becomes varx etc.SPS
 Remove
underscores from all variable names.SPS (can
be adapted to remove any other character)
 Rename variables.SPS
 Rename
all variables t2abc becomes t1abc etc.SPS
 Rename var in file1 to names in file2.SPS
 Reverse scale and value labels.SPS
 Round
and change format of all numeric variables.SPS
 Show 0.45 instead of
.45.SPS
 Sort
variable names by alphabetical order (AnswerNet).SPS
 Sort variables
by name in data file.sps (sent by A. Paul Beaulne)
 SortVariablesByAlphabeticalOrder.sps
 Write
value labels to ASCII file (AnswerNet).SPS
 Xpand vector names.SPS

Top 

 Compare 2 data files.SPS
with thanks to Simon Freidin
 Create data file if
double entries are equals.SPS (where entries
done by 2 different persons in 2 different files)
 Double entry check.SPS
 Find errors in 2 files (data entered twice).SPS
 Match one to many where key has 4 variables.sps
 Match 2 files using betweendates criteria.SPS
 Merge 2 data files
based on many to many relationship.SPS

Top 

 Coder
Reliability with Nominal Data.SPS for version 14+ of SPSS
with thanks to Pieter van
Groenestijn. Here are related notes
and references. Here are the syntax
for version 13 and
related notes
 Cohen's Kappa.SPS with
thanks to Brian G. Dates. This syntax provides complete information on
kappa for any number of raters and categories.
 Example that reads, writes, creates and transforms matrices.SPS
 Export variance
covariance matrix to ASCII file.SPS
 Export variance
covariance matrix to sav file.SPS
 Find inverse of a matrix.SPS
 Fuzzy Crosstable using
Matrix command.pdf with thanks to Ruben P. Konig
 Hierarchical sort in MATRIX.SPS
with thanks to Kirill Orlov
 Macro autogenerate initial data file.SPS
with thanks to Fernando Cartwright
 Matrix out in.SPS
 Maximizing the trace of a
matrix.SPS This is high powered stuff. Need to test all permutations
of rows in order to find the one which maximizes the trace. For a 7*7 matrix (the maximum
size this macro will handle), there are 5,040 permutations to test.
 Read matrix data.SPS
 Reliability
analysis when input is a correlation matrix.SPS
 Transform a matrix into a vector.SPS

Top 

 METASPSS.ZIP An
exhaustive set of syntax files written by Marta GarciaGranero
as well as sample data files and supporting documents. This is
the Read Me First
documentation.
 Meta Analysis: fixed
and random effects models.SPS (With thanks to Valentim R.
Alferes) This SPSS syntax does a metaanalysis on a set of studies
comparing two independent means. It produces results for both fixed
and random effects models, using Cohen's d statistics. The user has a
total of 10 modes for entering summary data.

Top 

 Count unique
occurences of a multiple response.SPS
 Create
dichotomous variables from multiple responses which are not in order.SPS
 Multiple responses are
encoded as comma separated letters.SPS

Top 

 Crosstab Chisquare and Phi in same table.SPS
 OMS and macros.SPS


Top 
 Outliers
Caution: Before replacing or deleting outliers, see the warning at the
beginning of syntax # 3.

 Exclude cases over mean plus 2 times sd.SPS
 Replace
outliers by average of cases with same characteristics.SPS
 Replace outliers by
mean plus/minus n times sd.SPS
 Winsorize a mean.SPS

Top 

 Extract bits from an integer.SPS
 Extract portion of string.SPS (string
contains first and last name, want first 3 letters of last name)
 Extract portion of string
starting with a digit.SPS
 Extract Zip code from
address field.SPS
 Extract two numbers from a
string.SPS (e.g. string "120/90" becomes numbers 120 and
90)
 Flag if last
characters of string are 'Esq'.SPS
 Parse a string into one letter per
variable.SPS
 Parse comma separated
numbers.SPS
 Parse data separated by
slashes.SPS
 Parse domain name from
email addresses.SPS
 Parse comma separated strings then autorecode results.SPS
 Parsing a
variable which has embedded line feeds.SPS (thanks to Bjarte Aagnes)
 Remove
letter at end of string and convert remaining string to a number.SPS
 Split
a string variable into plaintiff and defendant portions.SPS
 String
variable contains items separated by a slash.SPS
(there is a variable number of items from one case to the next)
 Weed out letters in a
string and create a number with remaining digits.SPS

Top 

 Complex sampling
without replacement.sps
 Draw
without replacement (random permutation of numbers).sps
 Generate random phone
numbers.sps (the syntax uses the following data file)
 Find random pairs of
cases for Ttest.sps
 Find
random pairs of cases with same characteristics.sps
 Flag n random
cases within each subgroups.SPS
 Get 2
independent samples meeting given criteria.sps
 Get 2 random samples
same sex age education.sps
 Get n independent random samples of size m from same file.SPS
 Get random
sample of x% of each stratum.SPS
 Get
random sample of N cases from each stratum.SPS
 Getting repeated
sampling from same file.sps
 List of random cases id
10 per line.SPS
 Match cases on
basis of propensity scores.SPS (this involves matching cases which
do not match but are close to each other)
 Proportional
sampling without replace.sps
 Proportional random
sampling.sps
 Proportional
sampling without replacement.sps
 Random sample n males
and n females.sps
 Random samples with
same age sex education.sps
 Random split a file in
two files.SPS
 Randomize
a variable n times and keep each randomization.SPS
 Scramble social insurance numbers.sps
 Select 2 cases from each
group.sps
 Select random samples
of each group.sps
 Split files in 2 random
portions.sps
 Split a file into 10
random groups of equal size.SPS
 Systematic fixed
sampling.sps

Top 

 Aggregating
with the median.SPS
 Calculate
cumulative sum of Var1.SPS
 Calculate mode.SPS
 Calculate
number of distinct values within Case.SPS
 Calculate
z scores across variables.SPS
 Code
using percentiles of a subset.SPS
 Compute
percentiles for one variable and by one or more grouping variables.SPS
(with thanks to Tom Dierickx). Note that the percentiles
end up in the data editor, not in the Output window.
 Compute
percentages based on values of first case.SPS
 Create
n tiles based on percent ranges rather than on count.SPS
 For each
case, find the earliest case in the preceding 7 days.SPS (relatively
complex stuff)
 Find
5 largest values within case.SPS
 Find
last 2 scores on repeated measure.SPS
 Find multimodal values per id.SPS
 Identify
the highest 3 scores of each case.SPS
 Identify
variables having minimum value.SPS (with thanks to Maciek Lobinski)
 New
variable equals cumulative totals by id.SPS
 Number
consecutively cases with the same id.SPS
 Random order.SPS
 Rank
equal intervals between minimum and maximum.SPS
 Rank
on basis of percentage of good.SPS
 Rank
variable names in alpha order.SPS
 Rank within
cases.SPS
 Replace
missing by median values within the case.SPS
 Round up
to the higher point 5.SPS
 Saving
confidence interval for mean (within groups).SPS
 Score a
test with an answer key.SPS (thanks to A. Paul Beaulne)
 Sorting
values within cases (using the bubble sort algorithm).SPS
 Syntax
group data in bands.SPS
 Various
Algorithms to sort within cases.SPSWith thanks to Kirill Orlov

Top 

Create
 Adding new cases
using syntax.SPS
 Add
variable equal to function of an existing Var.SPS
 A few simple examples of INPUT PROGRAM.SPS
(a short tutorial)
 Copy
some variables from each record type 1 to add a new record of type 0.SPS
 Create consecutive records at the end of the file.SPS
 Create
constants for each non missing date.SPS
 Define new
variables in empty data set.SPS
 Define varx to vary.SPS
 Duplicate
cases n times where n is variable.SPS (see also Expand Crosstab Data below)
 Expand
crosstab data into original data file.SPS (disaggregate data)
 Expand data x and y
times.SPS eg from a case where age=20, males=5
and females=6 want to create 5 cases with age 20 and sex=1 and 6 cases where age=20
and sex=0
 Fill the
gaps when Aggregate has empty categories.SPS Syntax creates
cases to fill the gaps
 Generate random dates.SPS
 INPUT
program (to generate a random data file).SPS
 Insert missing
cases (within id).SPS
 Insert missing dates
(within id).SPS
 Printing date time in
output.SPS
Read
 Example of data list.SPS
 Example of INPUT program.SPS
 Read a variable
number of records per case.SPS
 Read
ASCII (logical case is made up of 5 rows of 10 cases).SPS
 Read ASCII file
using FILE TYPE.SPS
 Read ASCII file
using INPUT PROGRAM.SPS
 Read
ASCII file with a forward slash delimiter.SPS
 Read
ASCII file with comma or dash delimited data .SPS
 Read
ASCII with comma and dot separated decimals.SPS
 Read
ASCII file with comma separated data (within quotes).SPS
 Read ASCII
file with fixed and free data.SPS
 Read ASCII file with
FIXED Data.SPS
 Read ASCII file with
REPEATING data.SPS
 Read
comma delimited fields with commas inside quoted strings.SPS
 Read comments
between the lines of data.SPS
 Read complex file.SPS
 Read data
files that has no carriage returns.SPS (from AnswerNet)
data is just one long stream, with no separation between records or fields, and
no carriage returns
 Read data list
free with consecutive commas.SPS
 Read data produced
by CGI script.SPS
 Read
data where each case has 4 numeric records and a variable number of string
records.SPS (this is illustrates the use of the REREAD
command)
 Read data
inline File Type MIXED Records.SPS
 Read text
file where n columns are to be ignored.SPS (n
is a variable which varies by file)
 Skip first 6 Records.SPS
 Skip one line of data.SPS
Write
 Write comma or tab
delimited file.SPS
 Write
frequency percentages to data file.SPS
 Write missing values
as a dot.SPS
 Write special ASCII
file.SPS
 Writing value
labels instead of values.SPS

Top 

 Add
casewise regression coefficients to data file.SPS
 BreuschPagan
& Koenker test.SPS (thanks to Marta GarciaGranero)
 Calculate
predicted values (unianova).sps
 Chow test.SPS
 Compare
regression coefficients.SPS (thanks to A. Paul Beaulne for sending
me this code)
 Compare coefficients generated by various groups.SPS
 Conditional
logistic regression.SPS
 Do
all univariate linear and logistic regressions.SPS
(thanks to Marta GarciaGranero)
 Do AllSubsets
regressions.SPS
 Generalized
Estimation Equations (GEE).zip (thanks to Terry Duncan, PhD,
Oregon Research Institute). GEE is a macro for analyzing
longitudinal data. The SPSS macro uses the GEE approach of Liang and
Zeger (1986) to model longitudinal data for a general class of outcome
variables including gaussian, poisson, binary and gamma outcomes.
 Logistic
regression by macro.SPS
 Multinominal
Logistic Regression with splitsample validation.sps (thanks
to Maciek Lobinski for sending me this macro)
 Non linear
regression (NLR) with variance of residuals as the loss function.SPS
(this is not trivial)
 Piecewise
regression.SPS (also known as "spline regression" and
"piecewise polynomials")
 Regression
calculates table of predicted values.SPS
 Regression in a loop.SPS
 Regression
when holding out k cases.SPS
 Regression
with correlation matrix as input.SPS
 Regression
with normed weight.sps
 Repeated measures
macro.SPS
 Ridge regression.SPS
(this comes with SPSS)
 Testing
individual regressors in logistic regression.SPS
 White's standard
errors full OLS and White's SE output.SPS (thanks to Gwilym Pryce)
See also the following related tutorials on
Heteroscedasticity.
 White's
test: calculate the statistics and its significance.SPS (thanks
to Marta GarciaGranero)

Top 

 Delete cases with
offset cases.SPS
 Delete double entries.SPS
(thanks to Maciek Lobinski) For instance if, for a
given case, var1 equals var2, the syntax replaces var2 by sysmis.
 Find duplicates.SPS
 Remove double quotes.SPS
 Remove duplicate
records.SPS
 Remove unused
variables from many files.SPS
 Replace
consecutive spaces in string by a single space.SPS
 Replace character In
string.SPS (see also String
Manipulation Tutorial)
 Save duplicates in a separate file.SPS

Top 

 Allocate dummy
variables to 24 hours.SPS
 Automated data
transform from tall to wide.SPS
 Automated
restructure v4.SPS
(thanks to Kevin Hynes) This
example maintains a grouping factor while restructuring data from tall
to wide.
 Automated
restructure from long to wide.sps with thanks to Hillel Vardi. This
is the sample data file used.
 Collapse empty
variables within a case.SPS
 Deduplicate
cases while keeping all the information.SPS (a cute little problem)
 Each variable
occupies 5 rows of 10 columns.SPS (an other nice little problem)
 Find
beginning and end of continuous periods.SPS
 From many to one example1.SPS
 From many to one example2.SPS
 From many to one with
alpha data.SPS
 From many
to one with specific order of new variables.SPS
 From one to Many simple.SPS
 From one to many
with indicator variable.SPS
 Restructure data file
example1.SPS
 Restructure data file
example2.SPS
 Restructure data file
example3.SPS
 Restructure data file
example4.SPS
 Restructure
from tall to wide (general solution).SPS (non trivial macro code...)
 Restructure time
periods to a time matrix.SPS
 Restructure to
calculate Kappa.SPS
 Transpose
(FLIP) string
variables.SPS
 Use former variable
names as value labels.SPS
Following examples require version 12 or above
 VarsToCases and CasesToVars.SPS

Top 

 ROC curves & Youden's Index.SPS The
syntax also computes Likelihood Ratios and KullbackLeiber distances
(requires v12 or above).


Top 

 Power analysis
examples.SPS With thanks to
Bruce Weaver
 Sample size for means.SPS
With thanks to Marta GarciaGranero. This is a
collection of several short macros that perform sample size
calculations for confidence interval estimation and one sample / two
samples tests for means (this last one with equal or unequal sample
sizes).
 Sample size for proportions.SPS
With thanks to Marta GarciaGranero. A collection of
macros that perform sample size calculation for the estimation of
one proportion and one or two samples hypothesis testing, as well as
the calculation of the power of a test.
 Sample size for correlation hypothesis testing.SPS thanks to Marta!

Top 

 Automated
data transform from tall to wide.SPS
 Choice of
include file depends on data.SPS
 End of macro DO
LOOP comes from data.SPS
 Execute
selective portions of syntax.SPS see also
tips on INCLUDE command
 From 2 files to 1 cases
per id.SPS
 Syntax varies
based on name of data file.SPS

Top 

 Are all words
present.SPS This tests whether all words passed to the macro are
present within a given string variable.
 Are all words present
dichotomy vars.SPS Similar to above but creates one dichotomy
variables for each target word
 Change all strings in data file to lower case.SPS
 Convert numbers to strings.SPS
 Convert string
'250 million' into a number.SPS (or '16 billion' etc)
 Convert string to numeric variable.SPS
 Soundex
Phonetic Comparison.SPS

Top 

 Show
95pc CI for failure points on a survival plot.SPS
 Survival Analysis Example.SPS



 Index of dissimilarity.SPS
(formulas from Negroes in Cities (1965) by Karl and Alma Taeuber)
 Many tests of inequality v5.SPS
(this chart template is used by the
syntax)

The above syntax (formulas come from poorcity.richcity.org )
calculates the following indexes:

the ATKINSON index = DEMAND coefficient.
the THEIL redundancy.
the RESERVE coefficient.
the D&R coefficient.
the KULLBACKLIEBLER redundancy.
the HOOVER coefficient.
the COULTER coefficient.
the GINI coefficient.

The Lorenz curve is produced. The various indexes are plotted on the
same graph when there is data for more than one year. At the end, there are 9
examples about how to use the syntax.

Top 

 Check for existence of
file.SPS
 Choice
of include file depends on existence of a given variable.SPS
 Get all string or all numeric variables.SPS
(the 2 macros produced by this macro allow you to process all string or all numeric
variables in the data file)

Top 

 Gaussian Filter.sps

Top 

 Automatically rescale variable to be between 0 and 1.SPS
 Calculate utility of EuroQol
5D questionnaire.SPS with thanks to AJ Garcia Ruiz
 Constrain a variable to
a given interval.SPS(syntax is first given, then it is generalized
using 2 macros)
 Convert numbers to
string with leading zeros.SPS
 Create variable equal to zscores of an existing variable.SPS
 Extract fist or first 2 digits of a large integer.SPS
 Global autorecode.SPS
A nice problem: Autorecode many string variables where the
recode formula (eg a=1,b=2, etc) is the same for all variables even
though none of the variables have all possible values
 Replace confidential information eg a ssn by a new
(known) id.SPS
 Replace
values higher than n by the mean of the other values.SPS

Replace letter by 9999 then convert to number.sps
 Transform string coding
into numbers.SPS
(5A becomes 5.1; 7B
becomes 7.2; 9D becomes 9.4 etc)
 zip code syntax.zip
With thanks to Christopher Boyd. This zip file contains 2 syntax
files: one recodes zip into town; the other does the reverse. Zip
codes are those used by the US Census to generate zip code level
employment data.

Top 

 ANOVA A*B.SPS (thanks to
Valentim Alferes) This does an A*B Factorial ANOVA and calculates
variance components, measures of association, measures of effect size
and observed power. Works with raw data or published summary
statistics.
 ANOVA_Tables using
4 methods.SPS (thanks to Valentim Alferes) method
1:for Ns, Means and SDs; method 2 for Ns, Means and Variances; method
3 for Ns,Means and MS Error; method 4 for Means, Df num, Df den and MS
Error.
 Cochran
Hartley Critical Values.SPS This gives the tabulated critical
values at 5% and 1% for both HOV tests. Thanks to Marta GarciaGranero
 Compare mean of each hospital
with mean of all other hospitals.sps (nice little macro)
 Do a TTest with only the
Means, SD and Ns.SPS (uses ANOVA)
 Do
TTest with only means,SD and Ns.SPS (thanks to Marta GarciaGranero)
this includes Hartley's F test, the standard Ttest and Welch
test, asymptotic and non asymptotic 95% CI are calculated.
 Hotelling's T**2 &
Profile Analysis.SPS (thanks to Richard
MacLennan)
 Multiple MannWhitney tests.SPS
(using a macro to have a procedure inside a LOOP)
 ONEWAY with summary
data1.SPS Performs a ONEWAY ANOVA plus several Homogeneity of
Variances tests on summary data. Thanks to Marta GarciaGranero
 ONEWAY with summary
dataI2.SPS Performs several ONEWAY ANOVAS plus several Homogeneity
of variances tests on summary data. Any number of variables can be
analysed. Thanks to Marta GarciaGranero.
 Standardized effects size (Cohen
Glass and Hedges's d).SPS (with thanks to Marta) The effects size
and their standard errors are added to the data file.
 TTests and Likert scales.SPS
 TTest effect size
non overlap and power.txt
(thanks to
Valentim Alferes) User can either analyse raw data or reproduce the
SPSS TTest standard output using summary statistics in published
articles.

Top 

 Adjusted pvalues
algorithms.SPS thanks to Marta GarciaGranero
for this improved version of her code. References are included.
The code calculates adjusted pvalues using the following 8
methods:
Onestep: Bonferroni and Sidak,
Stepdown: Bonferroni (Holm's), Sidak (also called Holm'sSidak) and Finner.
Stepup: Hommel, Hochbeerg and Simes
 Calculate average percent
score.SPS
 Calculations on dynamic
columns.SPS
 Canonical correlation.sps
(this comes with SPSS)
 Fill in the gaps.SPS
(information in file has been left blank when it equals the information in the preceding
case, this syntax fills the gap)
 Fill in the gaps (within ID).SPS
 Interaction in factorial
designs when dependent variable is not normal.SPS Thanks to Marta
GarciaGranero for this code.
 Stop or
resume generating outputs in the output window.SPS

Top 

 Combine
many data files with same variables.SPS
alternative 1: the following script
works even when file names are unknown
alternative 2: Use the DOS command copy
*.txt newfile.txt to combine all txt files in the folder (thanks to Scott Clark
for this suggestion)

Combine any number of consecutively named sav files 50 at a time.SPS
 Combine many xls files into a single sav file.SPS
 Combine 2 data files many to many.SPS
 Data list is
outside the main syntax.SPS (illustrates how a syntax file can be
modified by syntax)
 Delete
cases contained in file2 from the main data file.SPS
 Erase files.SPS
 Example 1 using UPDATE command.SPS
 Example 2 using UPDATE command.SPS
 Get mean from 3
different files.SPS
 Include 200
syntax files by macro.SPS
 Keep
only cases from Master file whose id are in second file.SPS
 Macro to delete a list of files.SPS
 Many folders and many
files.SPS
 Process all
xls files in folder.sbs (this scripts works jointly
with this syntax
file)
 Run a macro on several
files.SPS
 Run
syntax on files whose names are derived from a data file.SPS
 Run
a macro on every file whose name is in a sav file.txt
 Save file1 file2
file3 etc by macro.SPS
 Split big
files into separate categories.SPS (create a different sav file for each value of a
numeric categorical variable)
 Split
big files into separate categories string var.SPS (create a
different sav file for each value of a string categorical variable)
 Split
file with kn cases into k files of n cases each.SPS
 Unusual file merge.SPS
 Show
number of differences, if any, between 2 files.SPS (to check double
entry of data). For additional examples, see Matching
data files

Top 

 Conditionally
replacing missing by mean.SPS
 Conditionally
replacing missing by mean example 2.SPS
 Delete variables that have only missing values.SPS
 Identifying the
3 types of missing values.SPS
 Hot Deck.SPS substitution
of missing values of X within STRATUM (thanks to Theo van der
Weegen)
 List
variable names with missing values and identify main elements of cases.SPS
 Listing Variables with missing values
(Per case).SPS with thanks to David Marso
 Mean substitution
in additive scale.SPS
 Missing values and DO IF.sps
 Recode certain dates as
missing.SPS
 Replace
"Blanks" by value from preceding case.SPS
 Replace missing by mean of category.SPS
 Replace
missing by median values within each case.SPS
 Replace
missing by random value taken from cases with valid value.SPS (see
Hot Deck.SPS above for a more general solution)
 Replace missing with
mean.SPS
