/*
   program: /local2/samples/census/us90miss.sas   

   purpose: to illustrate how to unpack allocation flags
            in the US 1990 Pums Persons Data.  This procedure
            is *not* necessary for any of the other census data files.

   input files: _census.us90pump

   output files: work.miss

   notes: This program works by unpacking a binary value which is
          stored in amiss2 (for aincome1-aincome8) and/or 
          amiss1 (for all other allocation flags).

   To run this program, copy it to one of your own directories, then use
   "sas.queue" to build and submit a LoadLeveler command file for this
   program.  For more detailed information, see 
     /local2/samples/sas/how.to.run.sas.samples

  revision history: 
    created by mnm 7/2/96
   
 */

options compress=yes;

* create a temporary datafile called mymiss;
Data mymiss;

  * read in us90pump data, be sure to keep amiss1 and amiss2 ;
  * put any other variables you want in keep statement below;
  Set _census.us90pump(keep = amiss1 amiss2);


  * include next 2 lines if you are obtaining aincome1-aincome8;
  Length amissCH2 $ 41;
  amissCh2 = put(amiss2, $binary16.);    

  * include next 2 lines if you are obtaining any allocation flags;
  * except for aincome1-aincome8;
  Length amissCH1 $ 41;
  amissCh1 = put(amiss1, $binary41.);

  * Delete the lines below which correspond to allocation flags you ;
  * do *not* wish to use;
  Length AAUGMENT  3;
  AAUGMENT    = input(substr(amissCH1,  1, 1), 1.);

  Length ARELAT1   3;
  ARELAT1     = input(substr(amissCH1,  2, 1), 1.);

  Length ASEX      3;
  ASEX        = input(substr(amissCH1,  3, 1), 1.);

  Length ARACE     3;
  ARACE       = input(substr(amissCH1,  4, 1), 1.);

  Length AAGE      3;
  AAGE        = input(substr(amissCH1,  5, 1), 1.);

  Length AMARITAL  3;
  AMARITAL    = input(substr(amissCH1,  6, 1), 1.);

  Length AHISPAN   3;
  AHISPAN     = input(substr(amissCH1,  7, 1), 1.);

  Length ABIRTHPL  3;
  ABIRTHPL    = input(substr(amissCH1,  8, 1), 1.);

  Length ACITIZEN  3;
  ACITIZEN    = input(substr(amissCH1,  9, 1), 1.);

  Length AIMMIGR   3;
  AIMMIGR     = input(substr(amissCH1, 10, 1), 1.);

  Length ASCHOOL   3;
  ASCHOOL     = input(substr(amissCH1, 11, 1), 1.);

  Length AYEARSCH  3;
  AYEARSCH    = input(substr(amissCH1, 12, 1), 1.);

  Length AANCSTR1  3;
  AANCSTR1    = input(substr(amissCH1, 13, 1), 1.);

  Length AANCSTR2  3;
  AANCSTR2    = input(substr(amissCH1, 14, 1), 1.);

  Length AMOBLTY   3;
  AMOBLTY     = input(substr(amissCH1, 15, 1), 1.);

  Length AMIGSTAT  3;
  AMIGSTAT    = input(substr(amissCH1, 16, 1), 1.);

  Length ALANG1    3;
  ALANG1      = input(substr(amissCH1, 17, 1), 1.);

  Length ALANG2    3;
  ALANG2      = input(substr(amissCH1, 18, 1), 1.);

  Length AENGLISH  3;
  AENGLISH    = input(substr(amissCH1, 19, 1), 1.);

  Length AVETS1    3;
  AVETS1      = input(substr(amissCH1, 20, 1), 1.);

  Length ASERVPER  3;
  ASERVPER    = input(substr(amissCH1, 21, 1), 1.);

  Length AYRSSERV  3;
  AYRSSERV    = input(substr(amissCH1, 22, 1), 1.);

  Length ADISABL1  3;
  ADISABL1    = input(substr(amissCH1, 23, 1), 1.);

  Length ADISABL2  3;
  ADISABL2    = input(substr(amissCH1, 24, 1), 1.);

  Length AMOBLLIM  3;
  AMOBLLIM    = input(substr(amissCH1, 25, 1), 1.);

  Length APERCARE  3;
  APERCARE    = input(substr(amissCH1, 26, 1), 1.);

  Length AFERTIL   3;
  AFERTIL     = input(substr(amissCH1, 27, 1), 1.);

  Length ALABOR    3;
  ALABOR      = input(substr(amissCH1, 28, 1), 1.);

  Length AHOURS    3;
  AHOURS      = input(substr(amissCH1, 29, 1), 1.);

  Length APOWST    3;
  APOWST      = input(substr(amissCH1, 30, 1), 1.);

  Length AMEANS    3;
  AMEANS      = input(substr(amissCH1, 31, 1), 1.);

  Length ARIDERS   3;
  ARIDERS     = input(substr(amissCH1, 32, 1), 1.);

  Length ADEPART   3;
  ADEPART     = input(substr(amissCH1, 33, 1), 1.);

  Length ATRANTME  3;
  ATRANTME    = input(substr(amissCH1, 34, 1), 1.);

  Length ALSTWRK   3;
  ALSTWRK     = input(substr(amissCH1, 35, 1), 1.);

  Length AINDUSTR  3;
  AINDUSTR    = input(substr(amissCH1, 36, 1), 1.);

  Length AOCCUP    3;
  AOCCUP      = input(substr(amissCH1, 37, 1), 1.);

  Length ACLASS    3;
  ACLASS      = input(substr(amissCH1, 38, 1), 1.);

  Length AWORK89   3;
  AWORK89     = input(substr(amissCH1, 39, 1), 1.);

  Length AWKS89    3;
  AWKS89      = input(substr(amissCH1, 40, 1), 1.);

  Length AHOUR89   3;
  AHOUR89     = input(substr(amissCH1, 41, 1), 1.);

  Length AINCOME1  3;
  AINCOME1    = input(substr(amissCH2, 1, 2), binary2.);

  Length AINCOME2  3;
  AINCOME2    = input(substr(amissCH2, 3, 2), binary2.);

  Length AINCOME3  3;
  AINCOME3    = input(substr(amissCH2, 5, 2), binary2.);

  Length AINCOME4  3;
  AINCOME4    = input(substr(amissCH2, 7, 2), binary2.);

  Length AINCOME5  3;
  AINCOME5    = input(substr(amissCH2, 9, 2), binary2.);

  Length AINCOME6  3;
  AINCOME6    = input(substr(amissCH2,11, 2), binary2.);

  Length AINCOME7  3;
  AINCOME7    = input(substr(amissCH2,13, 2), binary2.);

  Length AINCOME8  3;
  AINCOME8    = input(substr(amissCH2,15, 2), binary2.);

  * The drop statement is used to discard the variables used;
  * to create the allocation flags, and which are no longer needed;
  Drop amiss1 amiss2 amissCH1 amissCH2; 
Run;
