* ------------------------------------------------------------ *.
*  This command file was generated by SOEPINFO-WWW             *.
*  from the SOEP HOMEPAGE: http://www.diw-berlin.de/soep.      *.
*                                                              *.
*      !!! I M P O R T A N T  -  W A R N I N G !!!             *.
*  You alone are responsible for contents and appropriate      *.
*  usage by accepting the usage agreement.                     *.
* ------------------------------------------------------------ *.
*  To copy this command file to your own harddisk:             *.
*  Use your mouse or (CNTL-A) to select this text, then "copy" *.
*  (CNTL-C) then in your windows application, or in a text     *.
*  editor, "paste" (CNTL-V).                                   *.
* ------------------------------------------------------------ *.
*                                                              *.
*  Please report any errors of the SPSS code generated here    *.
*  to John Haisken-DeNew: jhaiskendenew@diw.de                 *.
* ------------------------------------------------------------ *.
*  WARNING: SPSS for UNIX only allows up to 99 files to        *.
*           be accessed in a single retrieval. This is hard    *.
*           coded by SPSS and we cannot change this. You may   *.
*           have to run your retrieval in smaller blocks.      *.
*  ----------------------------------------------------------- *.
*                                                              *.
set compession on.
set header off.  

* ----------------[ automatically pull HPFAD ]----------------- *.

get  file = 'o:\soep\lehre\hpfad.sav'
    /keep = hhnr    persnr  sex     gebjahr psample
        ahhnr   bhhnr   chhnr   dhhnr   ehhnr   fhhnr   ghhnr   hhhnr  
        ihhnr   jhhnr   khhnr   lhhnr   mhhnr   nhhnr   ohhnr   phhnr  
        qhhnr   rhhnr   
        anetto  bnetto  cnetto  dnetto  enetto  fnetto  gnetto  hnetto
        inetto  jnetto  knetto  lnetto  mnetto  nnetto  onetto  pnetto
        qnetto  rnetto.

* --------------[ balanced / unbalanced design ]--------------- *.

select if ( (anetto ge 1) or (bnetto ge 1) or (cnetto ge 1) or
            (dnetto ge 1) or (enetto ge 1) or (fnetto ge 1) or
            (gnetto ge 1) or (hnetto ge 1) or (inetto ge 1) or
            (jnetto ge 1) or (knetto ge 1) or (lnetto ge 1) or
            (mnetto ge 1) or (nnetto ge 1) or (onetto ge 1) or
            (pnetto ge 1) or (qnetto ge 1) or (rnetto ge 1) ).

* ----------------------[ define sample ]---------------------- *.

select if ( (hsample eq 1) or (hsample eq 2) or (hsample eq 3) or
            (hsample eq 4) or (hsample eq 5) or (hsample eq 6) ).

sort cases by hhnr hhnrakt.
save outfile = 'c:\temp\hpfad.sav'.

* -----------------[ automatically pull hhrf ]----------------- *.

get  file = 'o:\soep\lehre\hhrf.sav'
    /keep = hhnr    hhnrakt hrgroup
        ahhrf   bhhrf   chhrf   dhhrf   ehhrf   fhhrf   ghhrf   hhhrf  
        ihhrf   jhhrf   khhrf   lhhrf   mhhrf   nhhrf   ohhrf   phhrf  
        qhhrf   rhhrf.

sort cases by hhnr persnr.
save outfile = 'c:\temp\hhrf.sav'.

* --------------[ automatically create hmaster ]--------------- *.

match files file  = 'c:\temp\hpfad.sav'
           /table = 'c:\temp\hhrf.sav'
           /by      hhnr hhnrakt.
 
sort cases by hhnr hhnrakt.
save output = 'c:\temp\hmaster.sav'.

* -------------------------( pull AH )------------------------- *.

get  file = 'o:\soep\lehre\ah.sav'
    /keep = hhnr    ahhnr   
        ah46.

sort cases by hhnr ahhnr.
save outfile = 'c:\temp\ah.sav'.

* -----------------------( pull AHGEN )------------------------ *.

get  file = 'o:\soep\lehre\ahgen.sav'
    /keep = hhnr    ahhnr   
        atyphh1.

sort cases by hhnr ahhnr.
save outfile = 'c:\temp\ahgen.sav'.

* -------------------------( pull BH )------------------------- *.

get  file = 'o:\soep\lehre\bh.sav'
    /keep = hhnr    bhhnr   
        bh39.

sort cases by hhnr bhhnr.
save outfile = 'c:\temp\bh.sav'.

* -----------------------( pull BHGEN )------------------------ *.

get  file = 'o:\soep\lehre\bhgen.sav'
    /keep = hhnr    bhhnr   
        btyphh1.

sort cases by hhnr bhhnr.
save outfile = 'c:\temp\bhgen.sav'.

* -------------------------( pull CH )------------------------- *.

get  file = 'o:\soep\lehre\ch.sav'
    /keep = hhnr    chhnr   
        ch51.

sort cases by hhnr chhnr.
save outfile = 'c:\temp\ch.sav'.

* -----------------------( pull CHGEN )------------------------ *.

get  file = 'o:\soep\lehre\chgen.sav'
    /keep = hhnr    chhnr   
        ctyphh1.

sort cases by hhnr chhnr.
save outfile = 'c:\temp\chgen.sav'.

* -------------------------( pull DH )------------------------- *.

get  file = 'o:\soep\lehre\dh.sav'
    /keep = hhnr    dhhnr   
        dh51.

sort cases by hhnr dhhnr.
save outfile = 'c:\temp\dh.sav'.

* -----------------------( pull DHGEN )------------------------ *.

get  file = 'o:\soep\lehre\dhgen.sav'
    /keep = hhnr    dhhnr   
        dtyphh1.

sort cases by hhnr dhhnr.
save outfile = 'c:\temp\dhgen.sav'.

* -------------------------( pull EH )------------------------- *.

get  file = 'o:\soep\lehre\eh.sav'
    /keep = hhnr    ehhnr   
        eh42.

sort cases by hhnr ehhnr.
save outfile = 'c:\temp\eh.sav'.

* -----------------------( pull EHGEN )------------------------ *.

get  file = 'o:\soep\lehre\ehgen.sav'
    /keep = hhnr    ehhnr   
        etyphh1.

sort cases by hhnr ehhnr.
save outfile = 'c:\temp\ehgen.sav'.

* -------------------------( pull FH )------------------------- *.

get  file = 'o:\soep\lehre\fh.sav'
    /keep = hhnr    fhhnr   
        fh42.

sort cases by hhnr fhhnr.
save outfile = 'c:\temp\fh.sav'.

* -----------------------( pull FHGEN )------------------------ *.

get  file = 'o:\soep\lehre\fhgen.sav'
    /keep = hhnr    fhhnr   
        ftyphh1.

sort cases by hhnr fhhnr.
save outfile = 'c:\temp\fhgen.sav'.

* -------------------------( pull GH )------------------------- *.

get  file = 'o:\soep\lehre\gh.sav'
    /keep = hhnr    ghhnr   
        gh42.

sort cases by hhnr ghhnr.
save outfile = 'c:\temp\gh.sav'.

* -----------------------( pull GHGEN )------------------------ *.

get  file = 'o:\soep\lehre\ghgen.sav'
    /keep = hhnr    ghhnr   
        gtyphh1.

sort cases by hhnr ghhnr.
save outfile = 'c:\temp\ghgen.sav'.

* -----------------------( pull GHOST )------------------------ *.

get  file = 'o:\soep\lehre\ghost.sav'
    /keep = hhnr    ghhnr   
        zh36.

sort cases by hhnr ghhnr.
save outfile = 'c:\temp\ghost.sav'.

* -------------------------( pull HH )------------------------- *.

get  file = 'o:\soep\lehre\hh.sav'
    /keep = hhnr    hhhnr   
        hh48.

sort cases by hhnr hhhnr.
save outfile = 'c:\temp\hh.sav'.

* -----------------------( pull HHGEN )------------------------ *.

get  file = 'o:\soep\lehre\hhgen.sav'
    /keep = hhnr    hhhnr   
        htyphh1.

sort cases by hhnr hhhnr.
save outfile = 'c:\temp\hhgen.sav'.

* -------------------------( pull IH )------------------------- *.

get  file = 'o:\soep\lehre\ih.sav'
    /keep = hhnr    ihhnr   
        ih49.

sort cases by hhnr ihhnr.
save outfile = 'c:\temp\ih.sav'.

* -----------------------( pull IHGEN )------------------------ *.

get  file = 'o:\soep\lehre\ihgen.sav'
    /keep = hhnr    ihhnr   
        ityphh1.

sort cases by hhnr ihhnr.
save outfile = 'c:\temp\ihgen.sav'.

* -------------------------( pull JH )------------------------- *.

get  file = 'o:\soep\lehre\jh.sav'
    /keep = hhnr    jhhnr   
        jh49.

sort cases by hhnr jhhnr.
save outfile = 'c:\temp\jh.sav'.

* -----------------------( pull JHGEN )------------------------ *.

get  file = 'o:\soep\lehre\jhgen.sav'
    /keep = hhnr    jhhnr   
        jtyphh1.

sort cases by hhnr jhhnr.
save outfile = 'c:\temp\jhgen.sav'.

* -------------------------( pull KH )------------------------- *.

get  file = 'o:\soep\lehre\kh.sav'
    /keep = hhnr    khhnr   
        kh49.

sort cases by hhnr khhnr.
save outfile = 'c:\temp\kh.sav'.

* -----------------------( pull KHGEN )------------------------ *.

get  file = 'o:\soep\lehre\khgen.sav'
    /keep = hhnr    khhnr   
        ktyphh1.

sort cases by hhnr khhnr.
save outfile = 'c:\temp\khgen.sav'.

* -------------------------( pull LH )------------------------- *.

get  file = 'o:\soep\lehre\lh.sav'
    /keep = hhnr    lhhnr   
        lh50.

sort cases by hhnr lhhnr.
save outfile = 'c:\temp\lh.sav'.

* -----------------------( pull LHGEN )------------------------ *.

get  file = 'o:\soep\lehre\lhgen.sav'
    /keep = hhnr    lhhnr   
        ltyphh1.

sort cases by hhnr lhhnr.
save outfile = 'c:\temp\lhgen.sav'.

* -------------------------( pull MH )------------------------- *.

get  file = 'o:\soep\lehre\mh.sav'
    /keep = hhnr    mhhnr   
        mh50.

sort cases by hhnr mhhnr.
save outfile = 'c:\temp\mh.sav'.

* -----------------------( pull MHGEN )------------------------ *.

get  file = 'o:\soep\lehre\mhgen.sav'
    /keep = hhnr    mhhnr   
        mtyphh1.

sort cases by hhnr mhhnr.
save outfile = 'c:\temp\mhgen.sav'.

* -------------------------( pull NH )------------------------- *.

get  file = 'o:\soep\lehre\nh.sav'
    /keep = hhnr    nhhnr   
        nh50.

sort cases by hhnr nhhnr.
save outfile = 'c:\temp\nh.sav'.

* -----------------------( pull NHGEN )------------------------ *.

get  file = 'o:\soep\lehre\nhgen.sav'
    /keep = hhnr    nhhnr   
        ntyphh1.

sort cases by hhnr nhhnr.
save outfile = 'c:\temp\nhgen.sav'.

* -------------------------( pull OH )------------------------- *.

get  file = 'o:\soep\lehre\oh.sav'
    /keep = hhnr    ohhnr   
        oh50.

sort cases by hhnr ohhnr.
save outfile = 'c:\temp\oh.sav'.

* -----------------------( pull OHGEN )------------------------ *.

get  file = 'o:\soep\lehre\ohgen.sav'
    /keep = hhnr    ohhnr   
        otyphh1.

sort cases by hhnr ohhnr.
save outfile = 'c:\temp\ohgen.sav'.

* -------------------------( pull PH )------------------------- *.

get  file = 'o:\soep\lehre\ph.sav'
    /keep = hhnr    phhnr   
        ph50.

sort cases by hhnr phhnr.
save outfile = 'c:\temp\ph.sav'.

* -----------------------( pull PHGEN )------------------------ *.

get  file = 'o:\soep\lehre\phgen.sav'
    /keep = hhnr    phhnr   
        ptyphh1.

sort cases by hhnr phhnr.
save outfile = 'c:\temp\phgen.sav'.

* -------------------------( pull QH )------------------------- *.

get  file = 'o:\soep\lehre\qh.sav'
    /keep = hhnr    qhhnr   
        qh54.

sort cases by hhnr qhhnr.
save outfile = 'c:\temp\qh.sav'.

* -----------------------( pull QHGEN )------------------------ *.

get  file = 'o:\soep\lehre\qhgen.sav'
    /keep = hhnr    qhhnr   
        qtyphh1.

sort cases by hhnr qhhnr.
save outfile = 'c:\temp\qhgen.sav'.

* -------------------------( pull RH )------------------------- *.

get  file = 'o:\soep\lehre\rh.sav'
    /keep = hhnr    rhhnr   
        rh49.

sort cases by hhnr rhhnr.
save outfile = 'c:\temp\rh.sav'.

* -----------------------( pull RHGEN )------------------------ *.

get  file = 'o:\soep\lehre\rhgen.sav'
    /keep = hhnr    rhhnr   
        rtyphh1.

sort cases by hhnr rhhnr.
save outfile = 'c:\temp\rhgen.sav'.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr ahhnr.

match files file = 'c:\temp\hmaster.sav'
          /table = 'c:\temp\ah.sav'
          /by      hhnr ahhnr.

match files file = *
          /table = 'c:\temp\ahgen.sav'
          /by      hhnr ahhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr bhhnr.

match files file = *
          /table = 'c:\temp\bhgen.sav'
          /by      hhnr bhhnr.

match files file = *
          /table = 'c:\temp\bh.sav'
          /by      hhnr bhhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr chhnr.

match files file = *
          /table = 'c:\temp\ch.sav'
          /by      hhnr chhnr.

match files file = *
          /table = 'c:\temp\chgen.sav'
          /by      hhnr chhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr dhhnr.

match files file = *
          /table = 'c:\temp\dh.sav'
          /by      hhnr dhhnr.

match files file = *
          /table = 'c:\temp\dhgen.sav'
          /by      hhnr dhhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr ehhnr.

match files file = *
          /table = 'c:\temp\eh.sav'
          /by      hhnr ehhnr.

match files file = *
          /table = 'c:\temp\ehgen.sav'
          /by      hhnr ehhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr fhhnr.

match files file = *
          /table = 'c:\temp\fhgen.sav'
          /by      hhnr fhhnr.

match files file = *
          /table = 'c:\temp\fh.sav'
          /by      hhnr fhhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr ghhnr.

match files file = *
          /table = 'c:\temp\gh.sav'
          /by      hhnr ghhnr.

match files file = *
          /table = 'c:\temp\ghgen.sav'
          /by      hhnr ghhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr ghhnr.

match files file = *
          /table = 'c:\temp\ghost.sav'
          /by      hhnr ghhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr hhhnr.

match files file = *
          /table = 'c:\temp\hh.sav'
          /by      hhnr hhhnr.

match files file = *
          /table = 'c:\temp\hhgen.sav'
          /by      hhnr hhhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr ihhnr.

match files file = *
          /table = 'c:\temp\ih.sav'
          /by      hhnr ihhnr.

match files file = *
          /table = 'c:\temp\ihgen.sav'
          /by      hhnr ihhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr jhhnr.

match files file = *
          /table = 'c:\temp\jhgen.sav'
          /by      hhnr jhhnr.

match files file = *
          /table = 'c:\temp\jh.sav'
          /by      hhnr jhhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr khhnr.

match files file = *
          /table = 'c:\temp\kh.sav'
          /by      hhnr khhnr.

match files file = *
          /table = 'c:\temp\khgen.sav'
          /by      hhnr khhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr lhhnr.

match files file = *
          /table = 'c:\temp\lh.sav'
          /by      hhnr lhhnr.

match files file = *
          /table = 'c:\temp\lhgen.sav'
          /by      hhnr lhhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr mhhnr.

match files file = *
          /table = 'c:\temp\mh.sav'
          /by      hhnr mhhnr.

match files file = *
          /table = 'c:\temp\mhgen.sav'
          /by      hhnr mhhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr nhhnr.

match files file = *
          /table = 'c:\temp\nhgen.sav'
          /by      hhnr nhhnr.

match files file = *
          /table = 'c:\temp\nh.sav'
          /by      hhnr nhhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr ohhnr.

match files file = *
          /table = 'c:\temp\oh.sav'
          /by      hhnr ohhnr.

match files file = *
          /table = 'c:\temp\ohgen.sav'
          /by      hhnr ohhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr phhnr.

match files file = *
          /table = 'c:\temp\ph.sav'
          /by      hhnr phhnr.

match files file = *
          /table = 'c:\temp\phgen.sav'
          /by      hhnr phhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr qhhnr.

match files file = *
          /table = 'c:\temp\qh.sav'
          /by      hhnr qhhnr.

match files file = *
          /table = 'c:\temp\qhgen.sav'
          /by      hhnr qhhnr.

* ------------( merge together by household: Wave ------------- *.

sort cases by hhnr rhhnr.

match files file = *
          /table = 'c:\temp\rhgen.sav'
          /by      hhnr rhhnr.

match files file = *
          /table = 'c:\temp\rh.sav'
          /by      hhnr rhhnr.

* --------------------( save output file )--------------------- *.

file label    "SOEPINFO: Magic at Work! http://www.diw.de/soep/".
save   outfile = 'c:\temp\new.sav'.
desc   all.

* -----------------( discard temporary files )----------------- *.

erase file = 'c:\temp\hpfad.sav'.
erase file = 'c:\temp\hhrf.sav'.
erase file = 'c:\temp\hmaster.sav'.
erase file = 'c:\temp\ah.sav'.
erase file = 'c:\temp\ahgen.sav'.
erase file = 'c:\temp\bh.sav'.
erase file = 'c:\temp\bhgen.sav'.
erase file = 'c:\temp\ch.sav'.
erase file = 'c:\temp\chgen.sav'.
erase file = 'c:\temp\dh.sav'.
erase file = 'c:\temp\dhgen.sav'.
erase file = 'c:\temp\eh.sav'.
erase file = 'c:\temp\ehgen.sav'.
erase file = 'c:\temp\fh.sav'.
erase file = 'c:\temp\fhgen.sav'.
erase file = 'c:\temp\gh.sav'.
erase file = 'c:\temp\ghgen.sav'.
erase file = 'c:\temp\ghost.sav'.
erase file = 'c:\temp\hh.sav'.
erase file = 'c:\temp\hhgen.sav'.
erase file = 'c:\temp\ih.sav'.
erase file = 'c:\temp\ihgen.sav'.
erase file = 'c:\temp\jh.sav'.
erase file = 'c:\temp\jhgen.sav'.
erase file = 'c:\temp\kh.sav'.
erase file = 'c:\temp\khgen.sav'.
erase file = 'c:\temp\lh.sav'.
erase file = 'c:\temp\lhgen.sav'.
erase file = 'c:\temp\mh.sav'.
erase file = 'c:\temp\mhgen.sav'.
erase file = 'c:\temp\nh.sav'.
erase file = 'c:\temp\nhgen.sav'.
erase file = 'c:\temp\oh.sav'.
erase file = 'c:\temp\ohgen.sav'.
erase file = 'c:\temp\ph.sav'.
erase file = 'c:\temp\phgen.sav'.
erase file = 'c:\temp\qh.sav'.
erase file = 'c:\temp\qhgen.sav'.
erase file = 'c:\temp\rh.sav'.
erase file = 'c:\temp\rhgen.sav'.

finish.