Pendelluft
Pendelluft

Reputation: 99

How to find max&min of all variables with SPSS and display in table?

I have a table with about 500 variables and 2000 cases. The type of these variables varies. My supervisor has asked me to produce a table listing all the numeric variables, along with their maximums and minimums. I am supposed to use SPSS because R apparently messes up the value labels.

I've only done very basic things in SPSS before this, like finding statistics for single variables, and I'm not sure how to do this. I think I should probably do something like:

*Create new table*
DATASET DECLARE maxAndMin.
*Loop through all variables: Use conditional statement to identify numeric variables*
DO REPEAT R=var1 TO varN.
FREQUENCIES VARIABLES /STATISTICS=MINIMUM
END REPEAT
*Find max and minimum*

I'm not sure how to go about this though. Any suggestions would be appreciated.

Upvotes: 2

Views: 562

Answers (2)

Rick Marcantonio
Rick Marcantonio

Reputation: 96

If SUMMARIZE produces a nice enough table for you, here is a "non-extension" way of doing it.

file handle mydata /name="<whatever/wherever>".

data list free /x (f1) y (a5) z (F4.2).
begin data.
1 yes 45.67
2 no 32.00
3 maybe .
4 yes 22.02
5 no 12.79
end data.

oms select tables
 /destination format=sav outfile=mydata
 /if subtypes="Descriptive Statistics" /tag="x".
des var all.
omsend tag="x".

get file mydata.
summarize Var1 Mean Minimum Maximum /format list nocasenum nototal
 /cells none /statistics none /title "Numeric Variables Only".

or use a DATASET command instead of file handle if you don't need the file on disk.

Upvotes: 0

eli-k
eli-k

Reputation: 11360

The following code will first make a list of all numeric variables in the dataset (and store it in a macro called !nums) and then it will run an analysis of those variables to tell you the mean, maximum and minimum of each:

SPSSINC SELECT VARIABLES MACRONAME="!nums" /PROPERTIES TYPE= NUMERIC.
DESCRIPTIVES !nums /STATISTICS=MEAN MIN MAX.

You can use the following code to create a tiny dataset to test the above code on:

data list list/n1 (f1) t1(a1) n2(f1) t2(a1).
begin data
1 "a" 34 "b"
2 "a" 23 "b"
3 "a" 52 "b"
4 "a" 71 "b"
end data.

Upvotes: 2

Related Questions