/*SHORT TITLE: Sample program using filetype MIXED    */

/*      NOTICE:  This program has been run, but EDS cannot guarantee
/*      its accuracy or suitability.  You will need to modify it to
/*      meet your needs.  Always check your results carefully, e.g.:
/*      by running frequencies or printing out a few cases.  If you
/*      find a problem, please report it to a consultant at EDS.      */


/* Each record type defines a case.
/* The record types are:

*        04 "State"
*        11 "County"
*        12 "MCD or CCD"
*        13 "Place within MCD, CCD, or county"
*        14 "Track"
*        15 "Block Group"
*        16 "Enumeration District"
*        27 "Place within state"
*        33 "Congressional District"

/* The following example gives labor force participation in individual 
/* counties.  
/* Table 55 list race by sex by labor force status.
/* Table 65 lists industry of employed person over age 15.
.

file handle ny /name="/eds/datasets/stf3a-80/data/stf3a80.nystate" lrecl=2016.
file type mixed  file=ny  record=recid 10-11.


* County record.
record type 11.
data list records = 6     
     /1
     county 40-42
     areaname 145-164 (A)
     /3
     tab55.01 to tab55.08 580-651
     tab65.01 to tab65.15 1459-1593
.
record type other skip.
end file type.

print formats tab55.01 to tab65.15 (comma11).


/* Compute new variables.
compute emplylf  = tab55.02+tab55.06.
compute millf    = tab55.01+tab55.05.
compute unemplf  = tab55.03+tab55.07.
compute totnilf  = tab55.04+tab55.08.
compute totcilf  = emplylf + unemplf.
compute totlf    = totcilf + millf.
compute totg16   = totlf + totnilf.
print formats emplylf to totg16 (comma11).

var labels  
   emplylf "Employed Labor Force"
   millf   "Military Labor Force"
   unemplf "Unemployed Labor Force"
   totnilf "Total Not In Labor Force"
   totcilf "Total Civilian Labor Force"
   totlf   "Total Labor Force"
   totg16  "Total Aged 16+"
.

/* Compute percentages of employed labor force in each industry (Table 65).
do repeat y=tab65.01 to tab65.15 /
    inds=affm cons mann mand tran 
         copu wtrd rtrd fire burs 
         pers hlth edse oprs padm.
compute inds=y/emplylf*100.
end repeat.

var labels
        affm "Agri,Forest,Fish,Mine"
        cons "Construction"
        mann "Non-durable Manufact"
        mand "Durable Manufacture"
        tran "Transportation"
        copu "Commun.,Pub.Util"
        wtrd "Wholesale Trade"
        rtrd "Retail Trade"
        fire "Finance,Insur.,R.Est."
        burs "Busines,Repair Serv."
        pers "Pers.,Entertain.,Rec."
        hlth "Health Services"
        edse "Educational Services"
        oprs "Other Prof. Services"
        padm "Public Administration"
.

freq vars=emplylf to totg16, affm to padm.

report format=list
   /variables=
        areaname  ' '   'County'(13)
        county    'County'  'Code'(7)
        totg16    'Number'  '16 or older'(11)
        totnilf   'Number not' 'in Labor'(11)
        millf     ' '   'Military'(11)
        unemplf   ' '   'Unemployed'(11)
        emplylf   ' '   'Employed'(11)
   /title 'County Labor Force Report'
   /break (nobreak)
   /summary=sum(totg16,totnilf,millf,unemplf,emplylf) 'Total'
.