Skip to main content
National Longitudinal Survey of Youth 1979 Child and Young Adult (NLSCYA)

Appendix E. Sample SPSSx Program for Merging NLSY79 Child/YA & Mother Files

/*********************************************************************

* Sample SPSSx program reads a child-based file extracted from the NLSY79 Child & 
Young Adult Data.
   It then reads a main Youth file extracted from the NLSY79 main Youth data set. 
* The two files are sorted by case ID and merged to create a child-based file with 
additional mother  characteristics attached to each child case ID.
* NOTE: Users who start with data in a system file format can skip the steps that 
read the ASCII files.
*********************************************************************/
file handle chdfile/name=Child file specifications.
file handle momfile/name=Mother file specifications.
file handle kidsdat/name=Temporary child-based system file.
file handle momsdat/name=Temporary mother-based system file.
 
data list file=chdfile records=1
   /1 C0000100  1-7
      C0000200  8-12
      C1526000  13-14
      C1531500  15-16
      C1531600  17-18.
 
compute kidflag=1.    /* Use flag to restrict final file after merge.   */
compute momid=C0000200.   /* Use same variable name for ID in files to be merged. /
 
variable labels momid  'ID Code Of Mother Of Child'.
variable labels C0000100  'ID Code Of Child'.
variable labels C0000200  'ID Code Of Mother Of Child'.
variable labels C1526000 'Child Conditn Reqires Attention fr Dr  96' .
variable labels C1531500  'Child Health Covered By Insurance     96' .
variable labels C1531600  'Child Health Covered By Medicaid      96'.
variable labels kidflag  'Observation From Child Dataset' /
 
sort cases by C0000100.     /* Sort by child ID  */
 
descriptives variables=all.
 
title 'NLSY79 Child: Sample merge program-Child & main Youth file' .
subtitle 'Extract child-based health insurance variables'.
frequencies general=C1526000 C1531500 C1531600/.
save outfile=kidsdat/.  
*********************************************************************
data list file momfile records=1
      /1 R0000100  1-5 
         R0214800  6-7
         R5625500  8-9
         R5625600  10-11
         R5625601  12-13
         R5625602  14-15
         R5625603  16-17
         R5625604  18-19
         R5625605  20-21
         R5625606  22-23.
 
compute momid=R0000100.   /* Use same var name for mom ID in both files. */
 
variable labels momid     'NLSY79 Identification Code (1-12686)  79'.
variable labels R0000100  'NLSY79 Identification Code (1-12686)  79'.
variable labels R0214800  'Sex Of R                              79'.
variable labels R5625500  'Children Have any Health-Hospitl Plan 96'.
variable labels R5625600  'Hlth Plan-Current Employer Policy     96'.
variable labels R5625601  'Hlth Plan-Previous Employer Policy    96'.
variable labels R5625602  'Hlth Plan-Spouse-Partnr Curr Employer 96'.
variable labels R5625603  'Hlth Plan-Spouse-Partnr Prev Employer 96'.
variable labels R5625604  'Hlth Plan-Direct Purchase frm Med Co. 96'.
variable labels R5625605  'Hlth Plan-Medicaid-Pub Assist-Welfare 96'.
variable labels R5625606  'Hlth Plan - Other Source              96'.
 
select if (R0214800=2). /* Restrict main Youth file to females */
 
sort cases by momid.
descriptives variables=all.
subtitle 'NLSY79 Females: Extract mother-based health insurance vars'.
 
save outfile=momsdat/ .
 
********************************************************************
match files table=momsdat/file=kidsdat/by momid.
select if (kidflag=1).
 
descriptives variables=all .
subtitle 'Check final merge of NLSY79 Child & Mother files' .
frequencies general=C1526000 C1531500 C1531600
                    R5625500 R5625600 R5625601
                    R5625602 R5625603 R5625604
                    R5625605 R5625606/format=onepage.
finish.