* This SAS program merges the 1983 Survey of Pension Providers data with the 1983 Survey of Consumer Finances Edited and Imputed Dataset. The number of observations from the 1983 SCF that match the 1983 SPP is 1,835. Users should note that 35 of these observations in the merged dataset come from uncleaned and unimputed cases in the 1983 SCF. For more detail on these cases, please refer to the 1983 SCF codebook.; LIBNAME SCF 'scf dataset library'; LIBNAME OUT 'output dataset'; FILENAME LINK83 'ASCII flatfile, spp83merge.txt'; FILENAME PENDAT 'ASCII flatfile, spp83data.zip' LRECL=18471; * Read in the file that links pension plans to 1983 SCF cases; DATA LINK83; INFILE LINK83 PAD; INPUT @1 PENPLAN 4. @8 HHID 5. ; B1 = INT(HHID/10); RUN; * Sort data by plan number for merging; PROC SORT DATA=LINK83; BY PENPLAN; RUN; PROC PRINT DATA=LINK83; RUN; * Reading in the 1983 SPP data, the variables listed are necessary for linking the two datasets, users can add any other desired variables from the pension provider file; DATA PENDAT; INFILE PENDAT MISSOVER; INPUT @1 CODEID 6. @7 SEQNUM 4. @11 PPID 4. @15 PLAN 3. @18 ATTACH 1.; PENPLAN=CODEID; RUN; * Sort data by plan number for merging; PROC SORT DATA=PENDAT; BY PENPLAN; RUN; PROC PRINT DATA=PENDAT; RUN; * Merge the link data (link83) and the main pension provider data (pendat) by the plan number; DATA ALLPEN; MERGE LINK83 PENDAT; BY PENPLAN; RUN; * Sort the merged pension data by the SCF household id number; PROC SORT DATA=ALLPEN; BY B1; RUN; PROC PRINT DATA=ALLPEN; RUN; * Read in the 1983 SCF data; DATA SCF83; SET SCF.1983 SCF dataset; * If the case was swapped (for an explanation of swapping, please see the 1983 codebook), need to reswap data to match the pension provider data. The variables listed below are the pension variables for the respondent and the spouse/partner. NOTE: Users may want to include other work status/history variables in the reswapping; IF B3122 = 2 THEN DO; ARRAY HEAD {*} B4501-B4522 B4531-B4567 B4701-B4723 B4731-B4753 B4761-B4783 B4901-B4931 B4941-B4949 B4961-B4990 B5101-B5121; ARRAY SPP {*} B4601-B4622 B4631-B4667 B4801-B4823 B4831-B4853 B4861-B4883 B5001-B5031 B5041-B5049 B5061-B5090 B5201-B5221; DO I=1 TO DIM(HEAD); TEMP1=HEAD{I}; TEMP2=SPP{I}; HEAD{I}=TEMP2; SPP{I}=TEMP1; END; END; RUN; * Sort the 1983 SCF data by household id; PROC SORT DATA=SCF83; BY B1; RUN; * Merge the pension provider data with the 1983 SCF data by household id; * Note the use of proc sql, this is needed for an unequal many to many merge (note: a warning message will be produced); PROC SQL; CREATE TABLE OUT.PEN83 AS SELECT * FROM ALLPEN INNER JOIN SCF83 ON ALLPEN.B1 = SCF83.B1; QUIT; RUN; PROC PRINT DATA=OUT.PEN83; RUN; ENDSAS;