==> 3year_test.sas <== /* this program is used to help convert acsskin and acsprofiles to using periods (1 year, 3 year, or 5 year). We modify the areanme to contain a 3 so we know we are using the correct dataset. */ libname acs '/pub/data/acs2007'; proc sql; update acs.usmcdcprofiles3yr set areaname='3yr ' || areaname; quit; ==> ACSsfGeo.sas <== /* Process ACS Summary File Geographic File */ LIBNAME census 'S:\dataproducts\2007\acs summary file\ACS-SF 2007 Final Documents\Sample SAS Programs\'; TITLE "g20071co.txt"; DATA census.g20071co; INFILE 'X:\tab4\sumfile\prod\2007\geo\g20071co.txt' MISSOVER TRUNCOVER LRECL=416; LABEL FILEID='File Identification' STUSAB='State Postal Abbreviation' SUMLEVEL='Summary Level' COMPONENT='Geographic Component' LOGRECNO='Logical Record Number' US='US' REGION='Region' DIVISION='Division' ==> acspopests.sas <== x cd /pub/data/acs2007/Tools; %let pgm=acspopests; filename pgm "&pgm..sas"; *---Part of the "CPR" estimating of ACS data for smaller counties (w. < 65000 pop) process. We want to start our new estimates by tapping into data from the official Census intercensal estimates. jgb, 1/26/2009 ----*; %let debug=1; %let year=2007; *<---the data year. Correspongs to the data directory we submit from (e.g. acs2007/Tools) ---; %let yearm1=%eval(&year-1); %let yearm2=%eval(&year-2); %let yr=%substr(&year,3,2); %let yrm2=%substr(&yearm2,3,2); %let myrsfx=&yrm2._&yr; *--if year=2007 then myrsfx=05_07 --; ==> add_subjectgroup_to_profile_variables.sas <== /* adds the tablegroup and subjectgroup variables to the acs2006/profiles/variables dataset so that the acs2006 profiles can be in the order of demographic, economic, social, and housing */ *libname acs2006 '/pub/data/acs2006/profiles'; libname acs2007 '/pub/data/acs2007'; %let period=; data variables. set acs2007.variables. length SubjectGroup $50; ==> agg_cpr_hlspts.sas <== x cd /pub/data/acs2007/Tools; %let pgm=agg_cpr_hlspts; filename pgm "&pgm..sas"; *---Aggregate both 2000 census (sf32kacs) and 2007 3yr data (acs2007) to get "HLSPT"=High Level Suppressed Portion Totals . This is data that summarizes the areas that have no ACS data for the period and which we shall therefore be using when we apply our CPR (county-PUMA ratio) methodology. Instead of looking at ratios of county and PUMA we shall look at ratios of counties and the portion of the PUMA which has no data. This should provide significantly improved guesstimates. jgb, Feb, 2009 ----*; %let year=2007; %let yr=%substr(&year,3,2); %let yearm1=%eval(&year-1); %let yearm2=%eval(&year-2); %let yrm1=%substr(&yearm1,3,2); %let yrm2=%substr(&yearm2,3,2); %let myrsfx=&yrm2._&yr; *--so it it 05_07 when year=2007---; %let debug=1; title "&pgm: Aggregate to Higher Level Suppressed Portion Totals"; ==> aggmcdcprofile.sas <== x cd /pub/data/acs2007/Tools; %let pgm=aggmcdcprofile; filename pgm "&pgm..sas"; /*---Aggregate acs mcdcprofile data set(s) using %agg macro and taking advantage of metadata sets to automate somewhat. jgb, 2/09. ---*/ libname acs2007 "/pub/data/acs2007"; libname cprdata '/pub/data/acs2007/cprdata'; %libname( corrlst ); /* =======================Begin comment================ ======================End comment================== */ data acs2007.mopumaprofiles3yr(label='MO subset of usmcdcprofiles w PUMA summaries only'); set acs2007.usmcdcprofiles3yr; where state='29' and sumlev='795'; drop geocomp_name county--placefp sdelm--cbsayr; ==> applycpr3yr_jgb.sas <== x cd /pub/data/acs2007/Tools; %let pgm=applycpr3yr_jgb; filename pgm "&pgm..sas"; *---Allocated ACS data for smaller (<20000) Mo counties using 3yr period data and the County-PUMA Ration ("cpr") method. Specifically, this module is set up to handle generating 3yr period estimates for all MO counties except those over 65K using ACS 2005-2007 3yr period estimates. The CPR ratios are derived from the county and PUMA level summaries in the sf32kacs filetype directories. Basic demographic "starter" data comes from the census estimates datasets as processed in job acspopests in this same Tools directory. Redundnant coding being done by bce so that we can compare results and evaluate. jgb, Jan, 2009 ----*; %let year=2007; %let yr=%substr(&year,3,2); %let yearm1=%eval(&year-1); %let yearm2=%eval(&year-2); %let yrm1=%substr(&yearm1,3,2); %let yrm2=%substr(&yearm2,3,2); %let myrsfx=&yrm2._&yr; *--so it it 05_07 when year=2007---; %let debug=1; ==> applycpr3yr_template.sas <== x cd /pub/data/acs2007/Tools; %let pgm=applycpr3yr_template; filename pgm "&pgm..sas"; *---This is the starter file for coders to create versions of applying the County/PUMA Ratio method to estimate ACS data for smaller Missouri counties. Specifically, this module is set up to handle generating 3yr period estimates for all MO counties except those over 65K using ACS 2005-2007 3yr period estimates. The CPR ratios are derived from the county and PUMA level summaries in the sf32kacs filetype directories. Basic demographic "starter" data comes from the census estimates datasets as processed in job acspopests in this same Tools directory. Plan is to have 2 job created from this template: applycpr_bce and applycpr_jgb that will produce 2 output data sets that will need to be compared to insure a consistent methodology. ----*; %let year=2007; %let yr=%substr(&year,3,2); %let yearm1=%eval(&year-1); %let yearm2=%eval(&year-2); %let yrm1=%substr(&yearm1,3,2); %let yrm2=%substr(&yearm2,3,2); %let myrsfx=&yrm2._&yr; *--so it it 05_07 when year=2007---; ==> cnvt_census_to_mcdc.sas <== x cd /pub/data/acs2007/Tools; %let pgm=cnvt_census_to_sas; filename pgm "&pgm..sas"; /*--- After we create uscensusprofiles and basetables, we need to merge these two datasets together and create our own mcdc dataset. 9/18/2008 - bce ---*/ %let period=3yr; %let year=2005 to 2007; *libname user '/tmp/scratch/user'; libname acs2007 '/pub/data/acs2007'; libname profiles '/pub/data/acs2007/profiles'; ==> cnvt_census_to_sas.sas <== x cd /pub/data/acs2007/Tools; %let pgm=cnvt_census_to_sas; filename pgm "&pgm..sas"; /*--- After we create uscensusprofiles and basetables, we need to merge these two datasets together and create our own mcdc dataset. 9/18/2008 - bce Last run circa 2-11-09 (jgb) ---*/ *---rerun 3yr data mode to add geocodes, jgb, 1-8-09 (edited but not actually run again, yet) *<===================; %let period=3yr; %let year=2005 to 2007; /* %let period=1yr; ==> cnvt_geo_files.sas <== x cd /pub/data/acs2007/Tools; %let pgm=cnvt_geo_files; filename pgm "&pgm..sas"; *---Read data from the geo-header Summary files ascii files downloaded from ftp2.census.gov/acs2006/summaryfiles {OR SIMILAR} to create sas datasets. jgb, 9-08 12-08-08: Added code to do keyed lookup on georef.cbsacos to get cbsa, cbsatype and metrodiv assigned to 050 levels. ---*; %let period=3yr; %let subdir=%str(3yr/); %let period=%str(); %let subdir=%str(1yr/); %let year=2007; %let yr=%substr(&year,3,2); title "&pgm.: Convert &year &period Geographic headers Data"; libname acs2007 '/pub/data/acs2007'; *<====; ==> cnvtcsv_profile_to_sas.sas <== x cd /pub/data/acs2007/Tools; %let pgm=cnvtcsv_to_sas; filename pgm "&pgm..sas"; /*---After we go thru the gymnastics in acsprofiles2007.py (from P:\mcdc\acs2007\tools) to create the input csv files from the profiles within the various csv files as downloaded, we now convert those csv files to SAS datasets for the archive. BCE, OSEDA, under contract with the Missouri Census Data Center. Sept. 2008. Dec 2008, modified to take period into consideration (added period var) ---*/ libname profiles '/pub/data/acs2007/profiles'; ==> compare_profiles_data.sas <== x cd /pub/data/acs2007/Tools; %let pgm=compare_profiles_data; filename pgm "&pgm..sas"; *----Compare the ACS mcdcprofiles data sets as created at the PUMA level for the 1yr and the 3yr data released for 2007. Are we seeing significant differences in these values? J. Blodgett. 12/2008. ----*; options ps=60; libname acs2007 '/pub/data/acs2007'; libname temp '/tmp/scratch/userb'; title 'Compare ACS Data for Missouri PUMAs: BASE=1 yr (2007), COMPARE=2005-07 Period Estimates'; title2 "Selected Key Indicators"; * ods html file="&pgm..html"; %let cvars=PctOver85 MedianAge PctUnder18 PctOver18 PctOver65 PctFemales PctWhite1 PctBlack1 PctIndian1 PctAsian1 PctHispanicPop PctNonHispPop PctNonHispWhite MedianHHInc AvgHHInc PctNumHHRetInc AvgHHRetInc MedianFamInc AvgFamInc PctNonFamHHs MedianNonFamInc AvgNonFamInc MedianEarnings Pctpoor PctPovUnder18 PctPov18to64 PctPovOver65 PctPovFamily PctPovUnrelated ==> compare_years.sas <== x cd /pub/data/acs2007/Tools; %let pgm=compare_years; filename pgm "&pgm..sas"; *---look at the acs profiles data for 2007 vs 2006 to see if numbers appear to be reasonable----; libname newpros '/pub/data/acs2007/profiles'; libname oldpros '/pub/data/acs2006/profiles'; proc contents data=oldpros.uscensusprofiles noprint out=oldvars(keep=name); proc sort; by name; run; proc contents data=newpros.uscensusprofiles noprint out=newvars(keep=name); proc sort; by name; run; data _null_; merge oldvars (in=inold) newvars(in=innew); by name; if not (inold and innew) then put _all_; run; ==> create_basetables.sas <== x cd /pub/data/acs2007/Tools; %let pgm=create_basetables; filename pgm "&pgm..sas"; *----Setup to read the 2 monster csv files containing summary data (estimates and moes) for the entire country and turn them into a series of table-subset-based SAS base tables datasets. Coded by Billy Earney, OSEDA, with minor mods by jgb, November, 2008. Under contract with the Missouri Census Data Center. Revised to run with period parm, jgb 12-08. Can process 1-year or 3-year data based on parm specified. ----*; %let year=2007; %let period=1yr; %let period2=; %*--for 1-year estimates sometimes we need a null value instead of 1yr, like in data set names--; %let period=3yr; %let period2=3yr; libname acs "/pub/data/acs&year./"; libname basetbls "/pub/data/acs&year./basetbls"; libname user '/tmp/scratch2/userb'; ==> create_basetables_metadata.sas <== x cd /pub/data/acs2007/Tools; %let pgm=create_basetables_metadata; filename pgm "&pgm..sas"; *----We access the strngely named basetbls.merge_5_6_final dataset (from the xls file of the same name provided on the Census Bureau summary FTP server) and generate a pair of metadata sets describing the tables and variables in the detailed basetables collection. JGB, Nov, 2008. ****Logic for calculating indent_level needs to be replaced with an importing of indent levels from another source. BCE will be working on creating such a data source by running a special macro within Excel against the acs2007 tables xls file** ----*; libname acs '/pub/data/acs2007/'; %let btpath=%str(/pub/data/acs2007/basetbls); libname basetbls "&btpath"; libname user '/tmp/scratch/user'; title "&pgm: Generate Variable level metadata for basetbls data sets"; /* =======================Begin comment================ ==> create_basetables_view.sas <== /* create a view that merges all the ustabs* tables together */ libname data '/pub/data/acs2007/basetbls'; %let period=3yr; proc sql; drop view basetables. create view data.basetables&period as select a.*, b.*, c.*, d.*, e.*, f.* from ustabs00_07&period a, ustabs08&period b, ustabs09_16&period c, ustabs17_20&period d, ustabs21_24&period e, ==> create_variables_view.sas <== /* create a view that merges all the variable* tables together */ libname data '/pub/data/acs2007/basetbls'; proc sql; drop view data.variables; create view data.variables as select * from variables00_07 union select * from variables08 union select * from variables09_16 union select * from variables17_20 union ==> ilabels.sas <== label B00001i1="Total" B00002i1="Total" B01001Ai1="Total:" B01001Ai10="30 to 34 years" B01001Ai11="35 to 44 years" B01001Ai12="45 to 54 years" B01001Ai13="55 to 64 years" B01001Ai14="65 to 74 years" B01001Ai15="75 to 84 years" B01001Ai16="85 years and over" B01001Ai17="Female:" B01001Ai18="Under 5 years" B01001Ai19="5 to 9 years" B01001Ai2="Male:" B01001Ai20="10 to 14 years" ==> indicators_cpr1.sas <== x cd /pub/data/acs2007/Tools; %let pgm=indicators_cpr1; filename pgm "&pgm..sas"; *--- Create the key indicators data set for Missouri and its counties, as available for the latest single year, 2007. jgb, 10-30-2008. ----*; *<==============When updating for a new year be sure to change all occurrences of acs2007 to acsXXXX, where XXXX is the new year=; %let debug=1; %let libout=temp; %let year=2007; *<---the data year. Correspongs to the data directory we submit from (e.g. acs2007/Tools) ---; %let yr=%substr(&year,3,2); %let casrhlyr=07; *--The latest year for which we have casrh estimates. We put data for all years, including earlier ones. You can be accessing data for 2006 in dataset mocasrh07.----; title "acs2007/Tools/&pgm : Estimate ACS key_indicators data for smaller counties for &year"; %libname(popests); ==> invoke_dosets_basetbls.sas <== x cd /pub/data/acs2007/Tools; %let pgm=invoke_dosets_basetbls; filename pgm "&pgm..sas"; /*--Invoke the %doset macro to create observations in the Datasets dataset for the acs2007/basetbls directory. J. Blodgett, OSEDA, Nov., 2008 Rev. -- */ title "Job to Invoke doset Macro for Sets in acs2007/basetbls"; libname acs2007 '/pub/data/acs2007'; libname basetbls '/pub/data/acs2007/basetbls'; %let libnameg=basetbls; %let gyear=2007; *--gp is the blobal period parameter. Value can be 1 or 3--; ==> invoke_dosets_profiles.sas <== x cd /pub/data/acs2007/Tools; %let pgm=invoke_dosets_profiles; filename pgm "&pgm..sas"; /*--Invoke the %doset macro to create observations in the Datasets dataset for the acs2007 directory which contains key profiles data sets as well as geography sets. Does not include basetbls data which is handled separately. J. Blodgett, OSEDA, Dec., 2008 Rev. -- */ title "Job to Invoke doset Macro for Sets in acs2007"; libname acs2007 '/pub/data/acs2007'; %let libnameg=acs2007; %let gyear=2007; *-----Run this step ONLY ONCE------------------------------------------; ==> invoke_dovars.sas <== %let _revdate=%str(2/16/2009 11:03:37 AM); /* See: http://mcdc.missouri.edu/pub/data/acs2006/ACS2006_d_Variable_Definitions.xls to see defns of the D vars */ /* Variables on the sf32kacs variables data set that were not occurring on this data set as of 2-12-09: ERROR: The variable AGE15_17 in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable PCTAGE15_17 in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable MALEWORKER16 in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable PCTMALEWORKER16 in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable FEMALEWORKER16 in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable PCTFEMALEWORKER16 in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable PCTOVER16 in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable PCTOVER3 in the DROP, KEEP, or RENAME list has never been referenced. ERROR: The variable SPECRENTER in the DROP, KEEP, or RENAME list has never been referenced. ==> ivariable_list.sas <== INPUT Stab LogRecNo B00001i1 B00002i1 B01001Ai1-B01001Ai31 B01001Bi1-B01001Bi31 B01001Ci1-B01001Ci31 B01001Di1-B01001Di31 B01001Ei1-B01001Ei31 B01001Fi1-B01001Fi31 B01001Gi1-B01001Gi31 B01001Hi1-B01001Hi31 B01001Ii1-B01001Ii31 B01001i1-B01001i49 B01002Ai1-B01002Ai3 ==> mcdcprofiles_fixgeos.sas <== x cd /pub/data/acs2007/Tools; %let pgm=mcdcprofiles_fixgeos; filename pgm "&pgm..sas"; *---Re-merge the allgeos data set with the usmscdcprofiles (both 1yr and 3yr) to improve the geocodes. Hopefully, juist a 1-shot fix being run 1-10-09, jgb----------------; libname acs2007 '/pub/data/acs2007'; proc sort data=acs2007.allgeos force; by geoid; run; options compress=binary; * compresses all the datasets; %macro fixgeos(period=3yr); data acs2007.usmcdcprofiles&period.2 ; merge acs2007.allgeos&period(in=ingeos drop=name rename=(areaname=_areaname)) acs2007.usmcdcprofiles&period(in=indata ); by geoid; if not (ingeos and indata) then do; put '***geo not found on 1 set: ' ingeos= indata= geoid= areaname= ; ==> mlabels.sas <== label B00001m1="Total" B00002m1="Total" B01001Am1="Total:" B01001Am10="30 to 34 years" B01001Am11="35 to 44 years" B01001Am12="45 to 54 years" B01001Am13="55 to 64 years" B01001Am14="65 to 74 years" B01001Am15="75 to 84 years" B01001Am16="85 years and over" B01001Am17="Female:" B01001Am18="Under 5 years" B01001Am19="5 to 9 years" B01001Am2="Male:" B01001Am20="10 to 14 years" ==> mvariable_list.sas <== INPUT Stab LogRecNo B00001m1 B00002m1 B01001Am1-B01001Am31 B01001Bm1-B01001Bm31 B01001Cm1-B01001Cm31 B01001Dm1-B01001Dm31 B01001Em1-B01001Em31 B01001Fm1-B01001Fm31 B01001Gm1-B01001Gm31 B01001Hm1-B01001Hm31 B01001Im1-B01001Im31 B01001m1-B01001m49 B01002Am1-B01002Am3 ==> temp.sas <== libname acs2007 '/pub/data/acs2007'; proc datasets library=acs2007 nolist; modify usmcdcprofiles3yr(pw=); quit;