|
I have an impression that version 16 was supposed to have a way to save
variable views as new files. (was it a PYTHON application?) I think I have seen this discussed? Has anyone put this application together? I have a few hundred files (several years for each US State). I would like to concatenate the data view information into a single file. What I would like to end up with is a system file with a variable for the name of the source file and variables for the name, type, . . . decimals. The result would be one file with "stacked" variable views. If there were a PYTHON wrapper, it would either take all the files in a list or search for files with a certain pattern. The names of the files have 2 or 3 characters indicating the State followed by an underscore and the same remainder for the name of the file. For one set e.g., AR_mrgd.sas7bdat AZ__mrgd.sas7bdat CA1_mrgd.sas7bdat CA2_mrgd.sas7bdat ... WV_mrgd.sas7bdat All states have one file except CA which has 2 because there are so many schools. Other sets have 2 characters indicating the State and 4 character year portion, e.g., AL2003.sas7bdat AL2004.sas7bdat AL2005.sas7bdat AK2003.sas7bdat AK2003.sas7bdat AK2003.sas7bdat ... WV2005.sas7bdat Art Kendall Social Research Consultants ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Art Kendall
Social Research Consultants |
|
At 02:51 PM 5/18/2008, Art Kendall wrote:
>I have an impression that version 16 was supposed to have a way to >save variable views as new files. (was it a PYTHON application?) Python has access to the data dictionary, and can do all sorts of things with it. I'm surprised nobody's pointed out some module from Developer Central to write the data dictionary. There are two parts to the problem: writing the data dictionary for ONE file; and looping over a whole set of files, writing the data dictionary for each. The latter is a macro-looping problem, using 'macro' in the general sense; in this case, you're using Python as a high-powered macro processor. There are pre-Python solutions to both. For the 'macro' part, i.e. looping over the list of files, I'd write an SPSS program to read the output of the command-prompt DIR command, and write a few lines of code for each file, to specify the file and INSERT the code that does the work. For getting the data dictionary from one file, here's an OMS solution previously posted. I haven't used it for a long time, and can't vouch for any quirks. From posting Date: Wed, 6 Sep 2006 13:30:05 -0400 From: Richard Ristow <[hidden email]> Subject: Data dictionary in SPSS To: [hidden email] X-ELNK-Info: spv=0; X-ELNK-AV: 0 X-ELNK-Info: sbv=0; sbrc=.0; sbf=0b; sbw=000; This demo runs on the CARS.SAV file that comes with SPSS, but I added a variable to have one with a long name. 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 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
