# helper functions to find position of an item in a list _pos = $(if $(findstring $1,$2),$(call _pos,$1,$(wordlist 2,$(words $2),$2),x $3),$3) pos = $(words $(call _pos,$1,$2)) # Download period life tables from CDC National Vital Statistics Reports in Excel format ## CDC FTP URL prefix CDCFTPPFX = ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/Publications/NVSR/ ## Years for which CDC life tables are available at the FTP server CDCDATAYEARS = 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 ## FTP folder corresponding to each year in $CDCDATAYEARS CDCFTPDIR = 52_14 53_06 54_14 56_09 58_10 58_21 59_09 61_03 62_07 63_07 64_11 65_08 66_03 66_04 67_07 68_04 ## Years with .xls file extension for life tables instead of .xlsx CDCXLSYEARS = 2001 2002 2003 2004 2005 ## Years with lowercase filename for life tables (table* instead of Table*) CDCLCYEARS = 2001 2002 2003 2004 2016 ## Years with intercensal updated tables CDCICYEARS = 2001 2002 2003 2004 2005 2006 2007 2008 2009 ## Years with downloadable tables for non-Hispanic black and white groups CDCNHYEARS = 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 $(DATADIR)/cdc_life_tables/black_female%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=black_female$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table09$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/nhblack_female%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=nhblack_female$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table18$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/black_male%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=black_male$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table08$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/nhblack_male%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=nhblack_male$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table17$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/white_female%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=white_female$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table06$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/nhwhite_female%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=nhwhite_female$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table15$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/white_male%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=white_male$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table05$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/nhwhite_male%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=nhwhite_male$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table14$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/hispanic_female%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=hispanic_female$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table12$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/hispanic_male%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=hispanic_male$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table11$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xlsx $(DATADIR)/cdc_life_tables/male%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=male$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table02$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xls$(if $(findstring $*,$(CDCXLSYEARS)),,x) $(DATADIR)/cdc_life_tables/female%.xlsx : cd $(DATADIR)/cdc_life_tables && wget --output-document=female$*.xlsx $(CDCFTPPFX)$(word $(call pos,$*,$(CDCDATAYEARS)), $(CDCFTPDIR))/Table03$(if $(findstring $*,$(CDCICYEARS)),_Intercensal,).xls$(if $(findstring $*,$(CDCXLSYEARS)),,x) CDCYRXLSX = $(addsuffix .xlsx, $(CDCDATAYEARS)) CDCNHYRXLSX = $(addsuffix .xlsx, $(CDCNHYEARS)) download_life_tables : $(addprefix $(DATADIR)/cdc_life_tables/, $(addprefix hispanic_male, $(CDCNHYRXLSX)) $(addprefix hispanic_female, $(CDCNHYRXLSX)) $(addprefix nhblack_female, $(CDCNHYRXLSX)) $(addprefix nhblack_male, $(CDCNHYRXLSX)) $(addprefix nhwhite_female, $(CDCNHYRXLSX)) $(addprefix nhwhite_male, $(CDCNHYRXLSX)) $(addprefix black_female, $(CDCYRXLSX)) $(addprefix black_male, $(CDCYRXLSX)) $(addprefix white_female, $(CDCYRXLSX)) $(addprefix white_male, $(CDCYRXLSX)) $(addprefix male, $(CDCYRXLSX)) $(addprefix female, $(CDCYRXLSX))) # Convert CDC period life tables from Excel to dta files and combine into a single file for each year ## Auto-convert sas to stata when required $(DATADIR)/cdc_life_tables/%.dta: $(DATADIR)/cdc_life_tables/%.xlsx st $< $@ -y CDCYRDTA = $(addsuffix .dta, $(CDCDATAYEARS)) CDCNHYRDTA = $(addsuffix .dta, $(CDCNHYEARS)) life_tables_dta : $(addprefix $(DATADIR)/cdc_life_tables/, $(addprefix black_female, $(CDCYRDTA)) $(addprefix black_male, $(CDCYRDTA)) $(addprefix white_female, $(CDCYRDTA)) $(addprefix white_male, $(CDCYRDTA)) $(addprefix male, $(CDCYRDTA)) $(addprefix female, $(CDCYRDTA)) $(addprefix nhblack_female, $(CDCNHYRDTA)) $(addprefix nhblack_male, $(CDCNHYRDTA)) $(addprefix nhwhite_female, $(CDCNHYRDTA)) $(addprefix nhwhite_male, $(CDCNHYRDTA)) $(addprefix hispanic_female, $(CDCNHYRDTA)) $(addprefix hispanic_male, $(CDCNHYRDTA))) # There are two targets for $(BASEDIR)/cdc_nvsr_lifetable%.dta because there are life tables for (Non-)Hispanic groups on the FTP server only in 2006 and later. # The earlier years will fail dependency matching for the first target and then succeed in the second target. $(BASEDIR)/cdc_nvsr_lifetable%.dta : $(addprefix $(DATADIR)/cdc_life_tables/, $(addsuffix %.dta, black_female black_male white_female white_male male female nhblack_female nhblack_male nhwhite_male nhwhite_female hispanic_male hispanic_female)) FEM_Stata/Makedata/POPULATION/cdc_nvsr_lifetables.do cd FEM_Stata/Makedata/POPULATION && HISPDATA=1 YEAR=$* $(STATA) cdc_nvsr_lifetables.do $(BASEDIR)/cdc_nvsr_lifetable%.dta : $(addprefix $(DATADIR)/cdc_life_tables/, $(addsuffix %.dta, black_female black_male white_female white_male male female)) FEM_Stata/Makedata/POPULATION/cdc_nvsr_lifetables.do cd FEM_Stata/Makedata/POPULATION && HISPDATA=0 YEAR=$* $(STATA) cdc_nvsr_lifetables.do cdc_nvsr_lifetables : $(addprefix $(BASEDIR)/, $(addprefix cdc_nvsr_lifetable, $(CDCYRDTA)))