2

We have a large SPSS file, it's 5MB and has about 1400 variables. We are in the process of migrating everything to a database, and in order to configure the tables and forms etc. we need the metadata from the SPSS file, but in a specific custom format.

So if the variable view is like this:

+--------+------------------+---------+-------+----------+----------------+
| Name   | Label            | Type    | Width | Decimals | Values         |
+--------+------------------+---------+-------+----------+----------------+
| PATID  | Patient Id       | Numeric | 8     | 0        |                |
| DOB    | Date Of Birth    | Date    | 11    | 0        |                |
| SEX    | Sex              | String  | 1     | 0        | {F, Female}... |
| ICFORM | Informed consent | Numeric | 8     | 0        | {0, No}...     |
+--------+------------------+---------+-------+----------+----------------+

We need a metadata file in a custom format, something like this:

FieldName;Description;DataType;Width;Decimals;Choices
PATID;"Patient Id";Int;8;0;""
DOB;"Date Of Birth";Datetime;11;0;""
SEX;"Sex";radio;1;0;"F = Female, M = Male"
ICFORM;"Informed consent";radio;8;0;"0 = No, 1 = Yes"

We have a couple of more SPSS files so preferable I would like to do it with a SPSS syntax if possible. In this answer someone suggested using OMS to capture dictionary but I have no clue how that would work. When I try this:

DISPLAY dictionary.
OMS dictionary.

I just get an error:

Subcommand OMS. Unknown keyword or subcommand: dictionary.
Execution of this command stops.

BdR
  • 2,770
  • 2
  • 17
  • 36

2 Answers2

2

OMS is indeed what you need, but the full process will look like this:

DATASET DECLARE  vars.
OMS   /SELECT TABLES
  /IF COMMANDS=['File Information'] SUBTYPES=['Variable Information']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_ OUTFILE='vars' .
DATASET DECLARE  vals.
OMS  /SELECT TABLES
  /IF COMMANDS=['File Information'] SUBTYPES=['Variable Values']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_    OUTFILE='vals' .
display dictionary.
omsend.

You will now have two new datasets containing variable definitions and value labels for all variables.

eli-k
  • 10,898
  • 11
  • 40
  • 44
0

You do not need to export in any case the meta data into a new file. You can also import the meta data from a SPSS data file. The command for doing so is:

APPLY DICTIONARY FROM datafilename.sav
/SOURCE VARIABLES = varlist
/TARGET VARIABLES = varlist
/NEWVARS .

You can find the complete information on this in

IBM SPSS Statistics 26 Command Syntax Reference, Chapter 15 - APPLY DICTIONARY, p. 167ff

HTH.

Best Regards

Georg

Georg
  • 11
  • 3