/********************************************************************************/
/**** This program reads in the sas dataset and contains data steps to create     ****/
/**** the 13 experimental poverty measures for 2001.
/**** This will enable analysts to replicate the experimental poverty        ****/
/**** measures or appropriately recombine thresholds and income measures to  ****/
/**** examine new ones. Also included in this file are variable and value    ****/
/**** label statements.                                                      ****/
/**** For details on construction of various income and threshold measures,  ****/
/**** refer to the P60-205 report on Experimental Poverty Measures           ****/
/**** and its Appendix C.                                                    ****/
/********************************************************************************/


libname public 'F:/';                     

proc format;

value agefmt 
	0-17='Under 18 years' 
    18-64='18 to 64 years'
	65-high='65 and over'     
                            ;

value racefmt 
	1='White'
    2='Black'
    3='AIAN'
    4='API'  
              ;

value hofmt 
	1-7='Hispanic'
    other='not Hispanic'   ;

value kindfmt 
	1='in MC family' 
    2='in male hh fam' 
    3='in female hh fam'   ;

value regfmt 
	1='Northeast' 
    2='midwest' 
    3='south'
    4='west'  ;

value typefmt
	1='Primary family'
    2='nonfamily householder'
    3='related subfamily'
	4='unrelated subfamily'
	5='secondary individual'
              ;

value msfmt
  1=  'married sp present'
  3=  'married sp absent'
  4=  'widowed'
  5=  'divorced/separate '
  7=  'never married'  ;

value age11fmt
  1=  'lt 3'
  2=  '3 to 5'
  3=  '6 to 11'
  4=  '12 to 17'
  5=  '18 to 21'
  6=  '22 to 44'
  7=  '45 to 54'
  8=  '55 to 59'
  9=  '60 to 64'
  10=  '65 to 74'
  11=  '75+'      ;

  value sexfmt
  1='Male'
  2='Female';

  value racerfmt
  1='White non-Hispanic'
  2='White Hispanic'
  3='Black non-Hispanic'
  4='Black Hispanic'
  5='AIAN non-Hispanic'
  6='AIAN Hispanic'
  7='API non-Hispanic'
  8='API Hispanic'
  9='Hispanic';

 value fpersonr
  1='1 person'
  2='2 persons'
  3='3 persons'
  4='4 persons'
  5='5 persons'
  6='6 persons'
  7-high='7 or more persons ' ;

value adwk
  0='no workers in family'
  1-high='workers in family';

 value educfmt
  0=  'Not in universe (under 25)'
  1=  'No high school'
  2=  'high school dip'
  3=  'some college'
  4=  'college degree'  ;

 value prcitshp
  1=  'native'
  2=  'naturalized citizen'
  3=  'not a citizen' ;

value disfmt
 1='disabled'
 2='not disabled'
 3='niu (under 16 or over 64 years of age)' ;

value sevfmt
 .='niu (under 16 or over 64 years of age)'
 0='not severely disabled'
 1='severely disabled';

value health
1='excellent'
2='very good'
3='good'
4='fair'
5='poor'
6='niu' ;

value fheadfmt
0='not family head'
1='family head';

run;

data two; set public.povpu01;

    array poor{13} poor1-poor13;
    
curdate=177.1;
nl1=17036*177.1/166.6 *    scaleb * geo2;         /* cpi99, geo */          
nl2=17036*curdate/166.6 *    scaleb;                /* cpi99, NO GEO */         
nl3=18709 *    scaleb * geo2;         /* ce,geo */             
nl8=18709 * scaleb;                   /* ce, no geo */         

/***compute foop thresholds  using cpi spreadsheet figures *****/
/** use same percentage as ce threshold                    ****/
/**  p1 based on 1999 threshold                           ****/
nl4=(mooplin1 + fcsulin1) * geo2;             /*  cpi fcsum geo  */
nl6=(mooplin1 + fcsulin1);             /*  cpi fcsum nga*/

/***compute foop thresholds  using ce spreadsheet figures *****/

nl5=(mooplin2 + fcsulin2) * geo2;             /*  ce fcsum geo  */
nl7=(mooplin2 + fcsulin2) ;             /*  ce fcsum nga  */

/*********************    income definitions  ******************/

   def001= ftotval;

   def002 =  def001 -ffica + (fcapgain-fcaploss) - ffedtax-fsttax+feitc   /*def013*/
           + f_mv_fs + (input(fhoussub, 3.) * 12)
           + fmvfsl + fmvrsl +fengval;

   def003 = def001 -ffica + (fcapgain-fcaploss) - ffedtax-fsttax+feitc   /*no houssub in*/
           + f_mv_fs
           + fmvfsl + fmvrsl +fengval;

   def004 = def003 - combexpc + fmrcap - newmoop;    /*exp1 betson  */

   def005 = def003 - combexpc + fmrcap;              /*exp3  moopitt  */

   def006 = def003 - combexpc + fmrcap - newmoop + mooplin1;      /*exp4 cmb cpi nl*/

   def007 = def003 - combexpc + fmrcapce - newmoop;    /*exp1 betson ce */

   def008 = def003 - combexpc + fmrcapce;              /*exp3  moopitt ce */

   def009 = def003 - combexpc + fmrcapce - newmoop + mooplin2;      /*exp4 cmb ce nl*/

/**** compute poverty status  ***********/

do i=1 to 13;
  poor(i)=0;
end;

if ftotval lt fpovcut then poor1=1; /*Official poverty*/

if def004 lt nl1 then poor2=1;    /* msi - cpi   */
if def004 lt nl2 then poor5=1;     /* msi - cpi-nga  */
if def007 lt nl3 then poor8=1;    /* msi - ce   */
if def007 lt nl8 then poor11=1;    /*msi-ce-nga */
if def005 lt nl4 then poor3=1;    /* mit - cpi  */
if def005 lt nl6 then poor6=1;    /* mit - cpi-nga   */
if def008 lt nl5 then poor9=1;    /* mit - ce  */
if def008 lt nl7 then poor12=1;   /* mit-ce-nga */
if def006 lt nl4 then poor4=1;    /* cmb - cpi*/
if def006 lt nl6 then poor7=1;   /* cmb - cpi-nga  */
if def009 lt nl5 then poor10=1;   /* cmb-ce */
if def009 lt nl7 then poor13=1;   /* cmb-ce-nga*/

label
  poor1='official poverty '
poor2= 'msi-cpi'    
poor5= 'msi-cpi-nga'
poor8= 'msi'
poor3= 'mit-cpi'
poor6= 'mit-cpi-nga'   
poor9= 'mit'
poor4= 'cmb-cpi'
poor7= 'cmb-cpi-nga'
poor10= 'cmb ' 
poor11= 'msi-ce-nga'
poor12= 'mit-ce-nga'
poor13= 'cmb-ce-nga'
;
/** subgroups computed here   */

agecat=put(a_age, agefmt.) ;

race=put(a_race, racefmt.);

horg=put(a_reorgn, hofmt.);

famkind=put(fkind, kindfmt.);

famtype=put(ftype, typefmt.); 

age11=put(age, age11fmt.);

mms=put(ms, msfmt.);

sex=put(a_sex, sexfmt.);

racer=put(rac_hisp, racerfmt.);

fpersonsr=put(fpersr, fpersonr.);

adwk=put(adwkfmt, adwk.);

reg=put(region, regfmt.);

health=put(hea, health.);

sevdisab=put(severe, sevfmt.);

prcitshp=put(citshp, prcitshp.);

disab = put (dis, disfmt.);

educat=put (educ, educfmt.);

fhead=put (famhead, fheadfmt.);

label 

  curdate = 'Current CPI-U.  Obtained from the Bureau of Labor Statistics website'
  nl1='threshold used to estimate poor2 status'
  nl2='threshold used to estimate poor5 status'
  nl3='threshold used to estimate poor8 status'
  nl4='threshold used to estimate poor3 and poor4 status'
  nl5='threshold used to estimate poor9 and poor10 status'
  nl6='threshold used to estimate poor6 and poor7 status'
  nl7='threshold used to estimate poor12 and poor13 status'
  nl8='threshold used to estimate poor11 status'
  age11='11 category age recode'
  agecat='3 category age recode'
  race='3 category race recode'
  hisp='Hispanic indicator'
  adwk='presence of working adult in family'
  horg='Hispanic origin'
  def001 = 'Poverty definition 1'
  def002 = 'Poverty definition 2'
  def003 = 'Poverty definition 3'
  def004 = 'Poverty definition 4'
  def005 = 'Poverty definition 5'
  def006 = 'poverty definition 6'
  def007 = 'poverty definition 7'
  def008 = 'poverty definition 8'
  def009 = 'poverty definition 9'
  reg='Region'
  sex = 'Sex - Male/Female'
  mms='marital status recode'
  famkind = 'kind of family'
  famtype = 'type of family'
  health='health status'
  racer='race/hispanic origin recode'
  fhead = 'Family head of household'
  educ = 'educational attainment'
  f_mv_fs='family food stamps income'
  f_mv_sl='school lunch income'
  fengval='family energy assistance subsidy amt'
  feitc='family EITC amt'
  ffica='family social security taxes amt'
  ffedtax='family federal taxes amt'
  fsttax='family state taxesamt'
  fcapgain='family capital gains amt'
  fcaploss='family capital losses amt'
  geo2='geographic adjustment to threshold'
    nl1='threshold used to estimate poor2 status'
  nl2='threshold used to estimate poor5 status'
  nl3='threshold used to estimate poor8 status'
  nl4='threshold used to estimate poor3 and poor4 status'
  nl5='threshold used to estimate poor9 and poor10 status'
  nl6='threshold used to estimate poor6 and poor7 status'
  nl7='threshold used to estimate poor12 and poor13 status'
  nl8='threshold used to estimate poor11 status'
    scaleb='three parameter scale'
  fpovcut='official pov threshold for family'
  ftotval='total family income'
  agecat='3 category age recode'
  educ='educational attainment'
  race='3 category race recode'
  hisp='Hispanic indicator'
  fpersons='# persons in family'
  adwkfmt='presence of working adult in family'
  dis='disability indicator'
  severe='severe disability indicator'
  hea='health indicator'
  fkind='kind of family'
  ms='marital status indicator'
  famhead='family head indicator'
  ftype='family type'
  marsupwt='March supplement final weight'
  horg='Hispanic origin'
  combexpc = 'Combined work expenses'
  newmoop='medical out-of-pocket expenditures'
  fmrcap='Capped housing subsidy based FMR'
  fmrcapce='Capped housing subsidy based on CE thresholds'
  mooplin1='MOOP part of CPI FSCUM threshold'
  mooplin2='MOOP part of CE FSCUM threshold'
  fcsulin1 = 'FCSU (Food Clothing Shelter and Utilities) part of CPI FCSUM threshold'
  fcsulin2 = 'FCSU part of CE FCSU threshold'
  def001 = 'Poverty definition 1'
  def002 = 'Poverty definition 2'
  def003 = 'Poverty definition 3'
  def004 = 'Poverty definition 4'
  def005 = 'Poverty definition 5'
  def006 = 'poverty definition 6'
  def007 = 'poverty definition 7'
  def008 = 'poverty definition 8'
  def009 = 'poverty definition 9'
  fmvfsl = 'free school lunch'
  fmvrsl = 'regular priced school lunch'
  rac_hisp='Race and Ethnicity recode'
  region='Region'
  citshp = 'Citizenship Recode'
  famkind = 'kind of family'
  famtype = 'type of family'
  age = '11 category age recode'
  fpers = 'Number of persons in family recode 1-10+'
  fpersr = 'Number of persons in family recode 1-7+';
run;


proc freq;
     tables poor1-poor13 
	 poor1-poor13*racer
	 poor1-poor13*sex
	 poor1-poor13*famkind
	 poor1-poor13*famtype
	 poor1-poor13*horg
	 poor1-poor13*adwk
	 poor1-poor13*health
	 poor1-poor13*reg
	 poor1-poor13*disab
	 poor1-poor13*fhead
	 poor1-poor13*educat
	 poor1-poor13*sevdisab
	 poor1-poor13*agecat
	 poor1-poor13*age11
	 poor1-poor13*mms
	 poor1-poor13*fpersonsr
	 poor1-poor13*prcitshp
  ;
     weight marsupwt;
run;

proc contents data = two;
run;