Metadata

Data about data. SPSS stores metadata within it's 'fat' proprietary format (i.e. SAV). This includes formats, display alignment and width, variable and value labels, measure types (i.e. scale), and user missing values.

For details on variable formats, see Numeric Formats and String Formats.


View Metadata

To extract metadata from an SPSS data set, use: display dictionary. This command works on the active data set.

It outputs (within SPSS) three tables:

The parallel for external data files is:

sysfile info file="/path/to/file.sav".


Copy Metadata between Datasets

To copy metadata from an existing, formatted data set to another, use apply dictionary. This command works on the active data set.

***** DICT dataset *****.
new file.
input program.

* FOO and BAR will be common variables.
numeric FOO (F2).
string BAR (A2).
* HAM, SPAM, EGGS will either be mismatched or non-existent.
numeric HAM (F8.2).
string SPAM (A8).
numeric EGGS (F8).

end file.
end input program.
execute.

dataset name DICT.
dataset activate DICT.
variable labels
 FOO "FOO"
 BAR "BAR"
 HAM "HAM"
 SPAM "SPAM"
 EGGS "EGGS".
value labels
 /FOO EGGS
  1 "1"
  2 "2".
execute.


***** NEW dataset *****.
new file.
input program.

* FOO and BAR will be common variables.
numeric FOO (F2).
string BAR (A2).
* HAM, SPAM, EGGS will either be mismatched or non-existent.
numeric HAM (F5).
string SPAM (A2).
*numeric EGGS (F8).

end file.
end input program.
execute.
dataset name NEW.
dataset activate NEW.
apply dictionary from "DICT".

As expected, FOO and BAR have all metadata copied perfectly. The others have some unexpected behaviors.


CategoryRicottone