* Import HSB file 8082/HSB82ALL.POS

program define use_HSB80_8082_HSB82ALL

    if "$EDSH_NCES" == "" {
      display as error "Set global macro EDSH_NCES"
      error 601
    }

    clear

    label define BYPART 0 "NON PARTICIPANT" 1 "PARTICIPATED"
    label define FU1PART 0 "NON PARTICIPANT" 1 "PARTICIPATED"
    label define FUSTATUS 5 "DECEASED" 4 "REFUSED" 2 "UNAVAILABLE" 3 "UNLOCATABLE" 1 "PARTICIPATED"
    label define FUSTTYPE 4 "EARLY GRAD" 2 "DROPOUT" 3 "TRANSFER" 1 "IN SCHOOL"
    label define SOQFLAG 0 "NOT AVAILABLE" 1 "AVAILABLE"
    label define DOQFLAG 0 "NOT AVAILABLE" 1 "AVAILABLE"
    label define TRQFLAG 0 "NOT AVAILABLE" 1 "AVAILABLE"
    label define EGQFLAG 0 "NOT AVAILABLE" 1 "AVAILABLE"
    label define TESTFLAG 0 "NOT AVAILABLE" 1 "AVAILABLE"
    label define TRFLAG 0 "NOT SELECTED" 2 "SELECTED" 1 "PARTICIPATED"
    label define PARFLAG 0 "NOT AVAILABLE" 1 "AVAILABLE"
    label define TWINFLAG 0 "NOT A TWIN" 1 "TWIN"
    label define BYSCHDAT 0 "NOT AVAILABLE" 1 "AVAILABLE"
    label define FUSCHDAT 0 "NOT AVAILABLE" 1 "AVAILABLE"
    label define SCHSAMP 0 "REGULAR SAMPLE" 5 "REGULAR CATHOLIC" 6 "BLACK CATHOLIC" 7 "CUBAN HISPANIC CATH" 2 "CUBAN HISPANIC PUBL" 9 "OTHER PRIVATE" 8 "ELITE OTHER PRIVATE" 3 "OTHER HISPANIC PUBL" 1 "ALTERNATIVE SCHOOLS"
    label define SCHURB 2 "SUBURBAN" 3 "RURAL" 1 "URBAN"
    label define SCHREGN 5 "WEST SOUTH CENTRAL" 4 "EAST SOUTH CENTRAL" 6 "EAST NORTH CENTRAL" 7 "WEST NORTH CENTRAL" 2 "MIDDLE ATLANTIC" 9 "PACIFIC" 8 "MOUNTAIN" 3 "SOUTH ATLANTIC" 1 "NEW ENGLAND"
    label define SEX 2 "FEMALE" 1 "MALE"
    label define RACE 5 "WHITE" 4 "BLACK" 6 "OTHER" 2 "AMERINDIAN" 3 "ASIAN, PCFC ISLNDR" 1 "HISPANIC OR SPANISH"
    label define BYTEST 998 "MISSING" 999 "NON PARTICIPANT"
    label define BYTESTQ 4 "HIGHEST QUARTILE" 2 "2ND QUARTILE" 9 "NON PARTICIPANT" 8 "MISSING" 3 "3RD QUARTILE" 1 "LOWEST QUARTILE"
    label define BYSES 99 "NON PARTICIPANT" 98 "MISSING"
    label define BYSESQ 4 "HIGHEST QUARTILE" 2 "2ND QUARTILE" 9 "NON PARTICIPANT" 8 "MISSING" 3 "3RD QUARTILE" 1 "LOWEST QUARTILE"
    label define FUTEST 998 "MISSING" 999 "NON PARTICIPANT"
    label define FUTESTQ 4 "HIGHEST QUARTILE" 2 "2ND QUARTILE" 9 "NON PARTICIPANT" 8 "MISSING" 3 "3RD QUARTILE" 1 "LOWEST QUARTILE"
    label define FUSES 99 "NON PARTICIPANT" 98 "MISSING"
    label define FUSESQ 4 "HIGHEST QUARTILE" 2 "2ND QUARTILE" 9 "NON PARTICIPANT" 8 "MISSING" 3 "3RD QUARTILE" 1 "LOWEST QUARTILE"
    label define FYCONCPT 9 "NON PARTICIPANT" 8 "MISSING"
    label define FYLOCUS 9 "NON PARTICIPANT" 8 "MISSING"
    label define FYWORK 9 "NON PARTICIPANT" 8 "MISSING"
    label define FYFAMILY 9 "NON PARTICIPANT" 8 "MISSING"
    label define FYCOMMUN 9 "NON PARTICIPANT" 8 "MISSING"

    infile using "$EDSH_DCT/HSB80/8082/HSB82ALL.dct", using("$EDSH_NCES/HSB80/8082/HSB82ALL.POS")

    * 3 implied decimals for FUSES (can't use Stata's informat due to negative values)
    replace FUSES = FUSES / 1000

    * Remove duplicate records
    bysort ID: drop if _n > 1

    label data HSB80_8082_HSB82ALL

 end