Size: 631
Comment:
|
Size: 2373
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 4: | Line 4: |
<<TableOfContents>> |
|
Line 9: | Line 11: |
== Display Dictionary == | == View Metadata == |
Line 24: | Line 26: |
---- == 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. * HAM is a numeric variable with mismatched formats ([[SPSSFormats#Numerics|F8.2 in the source, F5.0 in the target]]). The target has been overwritten with the source format. * SPAM is a string variable with mismatched formats ([[SPSSFormats#Strings|A8 in the source, A2 in the target]]). The source format remains. * EGGS is defined in the source, but not the target. Its metadata is ''not'' copied over. When it is created after the `apply dictionary`, it is bare of metadata. * If the `newvars` subcommand is specified, EGGS will be copied over. |
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.
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:
- data file metadata
- variable metadata
- value label metadata
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.
HAM is a numeric variable with mismatched formats (F8.2 in the source, F5.0 in the target). The target has been overwritten with the source format.
SPAM is a string variable with mismatched formats (A8 in the source, A2 in the target). The source format remains.
EGGS is defined in the source, but not the target. Its metadata is not copied over. When it is created after the apply dictionary, it is bare of metadata.
If the newvars subcommand is specified, EGGS will be copied over.