I used the merge data/add variable function of SPSS. The shared variable of
the two files was UIC and the variable added was Zip Code. The variable Zip Code merged fine but it only merged the Zip Code of the first record. This leaves me with many blank records like this: UIC ZIPCODE 30045 92127 30045 30045 30045 30046 54561 I would hate to have input data for over 400,000 records. Help would be appreciated. Thanks in advance. |
One file will have 1 record per UIC "ziplist", and 1 file will have
multiple records for the same UIC "datafile". Open your data files, and use your dataset names below. ** sample data. DATA LIST FREE /UIC ZIPCODE (2A5). BEGIN DATA 30045 92127 30046 54561 END DATA. DATASET name ziplist. DATA LIST FREE / ID (F8.0) UIC (A5). BEGIN DATA 1 30045 2 30045 3 30045 4 30045 5 30045 6 30046 7 30046 END DATA. DATASET name datafile. *** open your files and update this section with your dataset names. DATASET activate datafile. MATCH FILES FILE = * /TABLE = ziplist /BY UIC. LIST. MATCH FILES FILE = datafile /TABLE = ziplist /BY zipcode. --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Phil Angelini Sent: Thursday, April 26, 2007 1:15 AM To: [hidden email] Subject: After the Merge I used the merge data/add variable function of SPSS. The shared variable of the two files was UIC and the variable added was Zip Code. The variable Zip Code merged fine but it only merged the Zip Code of the first record. This leaves me with many blank records like this: UIC ZIPCODE 30045 92127 30045 30045 30045 30046 54561 I would hate to have input data for over 400,000 records. Help would be appreciated. Thanks in advance. |
In reply to this post by angelini
Try this:
if (UIC = lag(UIC)) ZIPCODE = lag(ZIPCODE). meljr
|
In reply to this post by angelini
At 02:14 AM 4/26/2007, Phil Angelini wrote:
>I used the merge data/add variable function of SPSS. The shared >variable of the two files was UIC and the variable added was Zip Code. >The variable Zip Code merged fine but it only merged the Zip Code of >the first record. This leaves me with many blank records like this: Jim Marks is right about the syntax. Do do this from the menus (Data>Merge files>Add variables...), when you select "Match cases on key variables in sorted files" you'll see three selections below, of which you one will be selected: "* Both files provide cases" "* Non-active dataset is keyed table" "* Active dataset is keyed table" The first is the default, and is probably what you left standing. For your case, select whichever of the other options specifies the file with the ZIP codes as a 'keyed table'. (That is, the second option of the main file is active; the third, if the ZIP file is active.) |
Free forum by Nabble | Edit this page |