SPSS 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.


Examine 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".


Variable Labels

To apply labels to variables, try:

variable label foo "foo"
  bar "bar"
  baz "baz".


Value Labels

To apply labels to values, try:

add value labels foo 1 "1"
 2 "2"
 3 "3"
 /bar 1 "1"
 2 "2"
 3 "3"
 /baz "A" "A"
 "B" "B"
 "C" "C".

As demonstrated above, labels can be applied to string values.


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

SPSS/Metadata (last edited 2023-01-14 05:18:19 by DominicRicottone)