Last night I wrote(*),
>...if SPSS had something like SAS's PROC CONTENTS, to write a file's >data dictionary to an SPSS file. Here's how to do it using OMS. It writes the dictionary of the working file. Of course, loading the dictionary overwrites the working file. (I'm using pre-14 logic. In SPSS 14, if you didn't want to use Python, you could write the OMS output to a second dataset, and not have to overwrite the original file.) It's based on the CARS.SAV file that comes with SPSS, but I added a variable to have one with a long name. DISPLAY VARIABLES. File Information |-----------------------------|---------------------------| |Output Created |06-SEP-2006 13:08:42 | |-----------------------------|---------------------------| Variable Information |---------------|--------|---------------|-----------|------|------|--------| |Variable |Position|Label |Measurement|Print |Write |Missing | | | | |Level |Format|Format|Values | |---------------|--------|---------------|-----------|------|------|--------| |Variable_with_l|1 |<none> |Nominal |A8 |A8 | | |ong_name | | | | | | | |---------------|--------|---------------|-----------|------|------|--------| |mpg |2 |Miles per |Scale |F4 |F4 | | | | |Gallon | | | | | |---------------|--------|---------------|-----------|------|------|--------| |engine |3 |Engine |Scale |F5 |F5 | | | | |Displacement | | | | | | | |(cu. inches) | | | | | |---------------|--------|---------------|-----------|------|------|--------| |horse |4 |Horsepower |Scale |F5 |F5 | | |---------------|--------|---------------|-----------|------|------|--------| |weight |5 |Vehicle Weight |Scale |F4 |F4 | | | | |(lbs.) | | | | | |---------------|--------|---------------|-----------|------|------|--------| |accel |6 |Time to |Scale |F4 |F4 | | | | |Accelerate from| | | | | | | |0 to 60 mph | | | | | | | |(sec) | | | | | |---------------|--------|---------------|-----------|------|------|--------| |year |7 |Model Year |Ordinal |F2 |F2 |0 | | | |(modulo 100) | | | | | |---------------|--------|---------------|-----------|------|------|--------| |origin |8 |Country of |Nominal |F1 |F1 | | | | |Origin | | | | | |---------------|--------|---------------|-----------|------|------|--------| |cylinder |9 |Number of |Ordinal |F1 |F1 | | | | |Cylinders | | | | | |---------------|--------|---------------|-----------|------|------|--------| |filter_$ |10 |cylrec = 1 | |Ordinal |F1 |F1 | | | | |cylrec = 2 | | | | | | | |(FILTER) | | | | | |---------------|--------|---------------|-----------|------|------|--------| Variables in the working file OMS /SELECT TABLES /IF COMMANDS=['File Information'] SUBTYPES=['Variable Information'] /DESTINATION FORMAT=SAV OUTFILE=ATTRIBS VIEWER=NO. . DISPLAY VARIABLES. File Information |-----------------------------|---------------------------| |Output Created |06-SEP-2006 13:08:42 | |-----------------------------|---------------------------| OMSEND. GET FILE=ATTRIBS /DROP=COMMAND_ SUBTYPE_ LABEL_ /RENAME=(VAR1=NAME). LIST. List |-----------------------------|---------------------------| |Output Created |06-SEP-2006 13:08:42 | |-----------------------------|---------------------------| The variables are listed in the following order: LINE 1: NAME Position LINE 2: Label MeasurementLevel PrintFormat WriteFormat MissingValues NAME: Variable_with_long_name 1 Label: <none> Nominal A8 A8 NAME: mpg 2 Label: Miles per Gallon Scale F4 F4 NAME: engine 3 Label: Engine Displacement (cu. inches) Scale F5 F5 NAME: horse 4 Label: Horsepower Scale F5 F5 NAME: weight 5 Label: Vehicle Weight (lbs.) Scale F4 F4 NAME: accel 6 Label: Time to Accelerate from 0 to 60 mph (sec) Scale F4 F4 NAME: year 7 Label: Model Year (modulo 100) Ordinal F2 F2 0 NAME: origin 8 Label: Country of Origin Nominal F1 F1 NAME: cylinder 9 Label: Number of Cylinders Ordinal F1 F1 NAME: filter_$ 10 Label: cylrec = 1 | cylrec = 2 (FILTER) Ordinal F1 F1 Number of cases read: 10 Number of cases listed: 10 ............................ (*)"Re: Renaming variables - noncontinuous", Wed, 6 Sep 2006 00:49:21 -0400 |
Free forum by Nabble | Edit this page |