==> acspopests.sas <== x cd /pub/data/acs2008/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 (original version for 2007 data), 11/09 - version for 2008 data. ----*; %let debug=1; %let year=2008; *<---the data year. Correspongs to the data directory we submit from (e.g. acs2008/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=2008 then myrsfx=06_08 --; %let casrhlyr=08; *--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 "acs&year./Tools/&pgm : Estimate ACS pop estimates-based data for smaller counties for &year"; %libname(popests); libname cprdata "/pub/data/acs&year./cprdata"; %libname(acs&year); libname corrlst '/pub/data/corrlst'; libname nchsbri '/pub/data/popests/nchsbri' access=readonly; %*let state=17; %*let stab=il; %let state=29; %let stab=mo; options nosource; /* =======================Begin comment================ ======================End comment================== */ options source; title2 "Single Year Data - &year"; *-------------------1. Process equivalency files to get links for counties with no acs20xx data to "Parent PUMAs"--; %global bigcos; proc sql noprint; select put(county,$5.) as c into :bigcos separated by ' ' from acs&year..allgeos where state="&state" and sumlev='050'; %put &bigcos; *---We are not currently using the values of acsvars1 and acsvars2 as calculated here. Apparently. (jgb, 11/09) --; select variable_name into :acsvars1 separated by ' ' from acs&year..variables( where=( name ^=: 'Pct' and substr(table,1,2) in ('1.','2.'))); %put &acsvars1; select variable_name into :acsvars2 separated by ' ' from acs&year..variables( where=( name ^=: 'Pct' and substr(table,1,2) in ('3.','4.'))); %put &acsvars2; quit; proc summary data=corrlst.sbg2k_puma_&stab (where=(pop2k and index("&bigcos",county)=0) ) noprint nway; var pop2k; class county puma5; output out=countypumas sum=; run; ==> agg_cpr_mo3yr08.sas <== x cd /pub/data/acs2008/Tools; %let pgm=agg_cpr_mo3yr08; filename pgm "&pgm..sas"; *---Apply the "cpr" (county PUMA ratio) methodology to get estimated estimates of our standard ACS profiles data for Missouri small counties for 2006-2008 (3-year period estimates). ===== Makes use of the sf32kacs data sets created by setup in acs2007/Tools/agg_cpr_hlspts . Need to run setup acspopests in this same Tools directory to create the latest popests data sets. <==== John Blodgett, OSEDA (U of MO Columbia), Nov. 2009 =====Rerun 12-9-09 after fix to othercommute variable in sf32kacs data===== -Rerun 2-3-10 to fix problem with Naturalized and NonCitizen vars. See http://mcdc2.missouri.edu/pub/data/acs/cprmethod.html for a detailed description of the method. ----*; filename cprmacs '/pub/data/acs2007/Tools/cprmacros.sas'; %include cprmacs ; *<--View the code at http://mcdc2.missouri.edu/cgi-bin/browse?/pub/data/acs2007/Tools/cprmacros.sas@ --; %let year=2008; %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; *--multi-year suffix. It is 05_07 when year=2007---; %let debug=1; title "&pgm"; title2 "Doing Estimates of Small Mo Counties Using &year 3yr Data With HLSPTs"; libname user "/pub/data/acs&year./temp"; libname temp (user); libname temp07 "/pub/data/acs2007/temp"; *<---We put some stuff in here last year that we can reuse this year---; libname acs "/pub/data/acs&year"; libname cprdata "/pub/data/acs&year./cprdata"; libname sf32kacs "/pub/data/sf32kacs"; %let state=29; %let stab=mo; *---Code here to create the input data source via merging of data from the sf32kacs directory (county and puma data), the latest 3-year period estimates for the PUMAs, and the 3-year pop estimates data created in the acspopests setup.--; *<====Never comment out Phase 0. Accessing metadata and creating global parameters to be used in processing steps, below.===; ***************Phase 0: Create some metadata in global variables**********************; proc contents data=acs.usmcdcprofiles3yr(keep=_numeric_) noprint out=profilevarsall(keep=name ); run; *---Filter out the new variables having to do with health insurance since we have no equvialencies---; data profilevars moevars insurancevars; set profilevarsall; ***if index(name,'Insur')=0 and name ne 'TotPopNonInst' then output profilevars; *<---the filtering of TotPopNonInst caused error-; if index(upcase(name),'_MOE') then output moevars; else if index(name,'Insur')=0 then output profilevars; else output insurancevars; run; proc contents data= sf32kacs.sf3&stab.counties (keep=_numeric_) noprint out=sf32kvars(keep=name); run; ==> cpr_method_c17024.sas <== x cd /pub/data/acs2008/Tools; %let pgm=cpr_method_c17024; filename pgm "&pgm..sas"; *----Apply the CPR (county to PUMA ratio) method to estimate data for base table c17024 (age by poverty ratio). We use 2006-2008 period estimates data for estimating for the same period. J. Blodgett. 2/2010. ----*; %let acsyear=2008; *<---the acs vintage data year. The 2008 vintage data were released in 2009 and as of early 2010 are still the most current estimates.----; %let acsyr=%substr(&acsyear,3,2); %let acsyearm2=%eval(&Acsyear-2); %let acsyrm2=%substr(&acsyearm2,3,2); %let years=%str(&acsyearm2.-&acsyear); libname acsbtabs "/pub/data/acs&acsyear./basetbls"; %libname(acs2008); libname sf32000 "/pub/data/sf32000"; libname corrlst "/pub/data/corrlst"; libname cprdata '/pub/data/acs2008/cprdata'; libname temp '/pub/data/acs2008/cprdata/temp'; **filename cprmacs '/pub/data/acs2007/Tools/cprmacros.sas'; filename cprmacs '/pub/sasmacro/cprmacros.sas'; *<---this is new for this run, with new macro dodistp---; %include cprmacs ; *<--View the code at http://mcdc2.missouri.edu/cgi-bin/browse?/pub/data/acs2007/Tools/cprmacros.sas@ --; %let debug=1; *--global variable referenced by at least 1 of the cpr macros (applycpr)---; options nosource; %macro dtastep; %*--Data step for processing the 2k (sf3) census data. Making it a macro so we can run it twice---; TotPop=pct16i1; _over18=pct25i1; Over65=pct25i35 + pct25i76; Age18_64=_over18-Over65; Under18=Totpop- _over18; _totpopck=sum(of under18 age18_64 Over65); if _totpopck ne totpop then do; put '**logic problems with age variables: ' _over18= totpop= age18_64= over65= _totpopck= ; abort abend; end; PovUTotal= pct50i1; PovUunder18=sum(of pct50i2 pct50i13 pct50i24 pct50i35 pct50i46 pct50i57); PovUage18_64=sum(of pct50i68 pct50i79 pct50i90 pct50i101 pct50i112); PovUover65=sum(of pct50i123 pct50i134); array _ageratio(3,5) Under18pr1-Under18pr5 Age18_64pr1-Age18_64pr5 Over65pr1-Over65pr5; array pct50(*) pct50i1-pct50i144; _p50i=2; do _agei=1 to 13; *--Table pct50 has 13 age cohort repeats but we group them into just 3 categories. These are reflected by the index variables _agei which ranges from 1 to 13 and _age3i which only ranges from 1 to 3.---; if _agei=1 then _age3i=1; else if _agei=7 then _age3i=2; else if _agei=12 then _age3i=3; if _agei in (1,7,12) then do; *--a new 3-level age grouping begins. Set the counts to 0---; do _povratioi=1 to 5; ==> create_allgeos.sas <== x cd /pub/data/acs2008/Tools; %let pgm=create_allgeos; filename pgm "&pgm..sas"; *---Modeled after cnvt_geo_files setup from last year (acs2007/Tools). This year we do not go back to the raw ascii files from the Bureau. Instead, we access a sas data set created by Billy E on the other (Windows) platform and use it as the source of the geographic data, but then adding our own customizations. *** Once this job is successfully completed edit and run the create_basetbls job to complete creation of the basetbls datasets by merging the basetables datasets uploaded to the temp library with this acsXXXX.allgeos dataset. *** jgb, 9-09 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=2008; %let yr=%substr(&year,3,2); %let yearm1=%eval(&year-1); title "&pgm.: Convert &year &period Geographic headers Data"; libname acs&year "/pub/data/acs&year"; *<====; libname acs&yearm1 "/pub/data/acs&yearm1"; *<====; libname temp '/pub/data/temp'; %libname(georef); data allgeos. ***infile "/pub/data/acs2008/geos/&subdir.*.txt" truncover lrecl=415; length SumLev $3 geoid $20 Name $120 AreaName $100 Geocomp_Name $64 State Stab $2 SumLev $3 Geocomp $2 LogRecno 8 County $5 CBSA $5 cbsaType $5 UA $5 PlaceFP $5 PUMA5 $5 sdelm sdsec sduni $5 Region Division $1 CongDist $2 MetroDiv $5 CSA $3 NECTA $5. ; cbsaType=' '; CBSAYr=' '; *<--being retained because we did a keyed read below--; *** input @7 Stab $2. SumLev $3. Geocomp $2. LogRecNo 7. +1 Region $1. Division $1. @26 state $2. _cnty $3. cousubfp $31-35 placefp $36-40 cbsa $76-80 metrodiv $84-88 csa $81-83 necta $91-95 ua $104-108 CongDist $114-115 puma5 $166-170 @138 (sdelm sdsec sduni)($5.) @176 geoid $20. @216 Name $120.; *<----following sas data set was uploaded from P:\mcdc\acs2008\basetbls ---; set temp.allgeos&period(drop=fileid US statece tract blkgrp concit aia: aits anrc macc memi cneta nectadiv uacp sld: vtd zcta: submcd pci taz uga rename=(stusab=stab sumlevel=SumLev component=geocomp county=_cnty cousub=cousubfp place=placefp cdcurr=congdist areaname=name)); ***if state=' ' then state=_state2; if state='00' then state=' '; if stab=' ' and state=' ' then delete; length Geocode $12; geocode=substr(geoid,8); *---the codes identifying the area without SumLev and Geocomp and "US" from geoid-; if _cnty ne ' ' then County=State||_cnty; else County=' '; if geocomp ne '00' then do; Areaname=scan(name,1,';'); Geocomp_Name=scan(Name,2,';'); end; else Areaname=name; ==> create_basetables_metadata08.sas <== x cd /pub/data/acs2008/Tools; %let pgm=create_basetables_metadata08; filename pgm "&pgm..sas"; *<----Currently this setup will filter the metadata referening table B26001 because we had no data for it on 9-30-09. But we will in the future so we need to then remove that filter. Circa line 69. --------; *----We access two sources of ACS base table (aka "detail" or "summary" tables). One is a SAS data set (merge_5_6_final) and the other is a derived csv file the Billy Earney created from another downloaded xls file. See detailed notes below. The output here is a set of six metadata datasets stored in the basetbls library and six corresponding .txt metadata files stored in the basetbls/Varlabs directory. Adapted from setup create_basetables_metadata.sas in acs2007/Tools by J Blodgett, Sept. 2009. <====NOTE: go to basetbls and issue a mkdir Varlabs command to create the Varlabs subdirectory used here========= ====> After this step completes successfully go to /pub/websas/Tools/genTableSelects.sas . Edit and run that setup to create the series of includeable select stmts in /pub/webutil/selects/acs2008.html . This is what allows uex2dex and dexter to provide acccess to these base tables as tables rather than as individual variables. ----*; libname acs '/pub/data/acs2008/'; %let btpath=%str(/pub/data/acs2008/basetbls); libname basetbls "&btpath"; libname user '/tmp/scratch/user'; title "&pgm: Generate Variable level metadata for basetbls data sets"; *---Read the special csv file created from the acs_2008_tables.xll file by BCE to add an indent level field which we shall use later-; filename csvin '/pub/data/acs2008/basetbls/acs_2008_tables_indent_levels.csv'; *-----This file was created by Billy Earney as follows: I download a file named acs__tables.xls file that contains a shell of what the base tables look like. If everything is correct, the column descriptions are indented with spaces. I wrote a script called create_indent_level_csv_file.py that reads a csv version of the acs_2008_tables.xls file, and calculates the number of indent levels by just counting the number of spaces before each description. This file is located at /scripts/acs//detailedtables/labels/create_indent_level_c sv_file.py in the new environment, where period in this case is 2008. -----*; /* =======================Begin comment================ data indents; infile csvin dsd lrecl=300 truncover ; length tableId $8 TableCell 4 _c1 $1 _ctablecell $4 IndentLevel 4; input tableid _ctablecell; _c1=substr(tableid,1,1); if _c1 in ('B','C') and _ctablecell ne 'Tabl' and _ctablecell ne ' '; if verify(_ctablecell,' 1234567890')=0; _subject=substr(tableid,2,2); if '00' <= _subject <= '27'; *--flush tables in 98 and 99 series here--; if tableid='B02003' or tableid=:'B12008' then delete; if index(tableID,'PR') or substr(tableid,8,1)='P' then delete; *--This is like B06004APR, where we truncated the R--; tablecell=_ctablecell; indentlevel=scan(_infile_,-1,','); drop _: ; run; ==> create_basetbls_3yr.sas <== x cd /pub/data/acs2008/Tools; %let pgm=create_basetbls_3yr; filename pgm "&pgm..sas"; *---This job is only used to process the 3-year period data for 2008. We coded a separate create_basetbls.sas setup earlier to do similar processing of the 1yr data. We originally just uploaded the 3yr data from the datasets on the P: drive and did no merging of the geographic ids from the allgeos3yr dataset. But now we are going to do that standard processing.---; *---The base tables data sets are mostly created by Billy Earny on the new platform and are copied to the P: drive from which they are uploaded and stored in the temp directory. The allgeos data set also is stored there and is converted to the final copy by the create_allgeos setup in this program library. In this setup we create the final, permanent basetbls datasets by merging and renaming the ustabs datasets in temp with the final allgeos dataset. To summarize the process of creating the acs2008\basetbls 3yr data sets: 1. bce downloads the raw data from CB web site. These get converted to mysql and then to sas datasets. These are then copied to the P: drive (\mcdc\acs2008_3yr\basetbls ). These have the basic data but need work regarding some naming conventions and the addition of standard geographic data. 2. The state level geographic data files are processed by bce to create an allgeos3yr dataset which is also copied to the P: drive, acs2008_3yr\basetbls folder. 3. Setup upload_edit_basetbls3yr.sas is created (in the above basetbls directory on P:) and is run to upload the basetbls datasets to /pub/data/temp on this AIX site. We also upload a copy of that sas program file to this (Tools) directory. IMPORTANT NOTE: This is NOT what happened in Nov 2009 when we coded and ran this setup. The 3yr datasets were uploaded to the acs2008/basetbls directory instead of the temp directory and this setup was NOT then run to add the geo variables. We are just now dealing with this inconsistency in May of 2010. Better late than never. We went to the acs2008/basetbls dir and used cp *3yr* /pub/data/temp to put the uploaded datasets over in the temp directory where they belonged. And now we shall write over the original copies, creating new version that have been upgraded to include the geos. 4. We run the create_allgeos.sas setup here to access the uploaded temp.allgeos dataset and do final enhancements to it, creating acs2008.allgeos dataset. (NO - not really. We just use the dataset as uploaded here.) 5. This job (re)creates the ustabsXXXXX3yr and ustabswxxxxx_moes3yr datasets in /pub/data/acs2008/basetbls by merging the corresponding temp datasets with the acs2008.allgeos3yr dataset. jgb, 5-7-2010 ---*; %let period=3yr; %let subdir=%str(3yr/); %let year=2008; %let yr=%substr(&year,3,2); %let yearm1=%eval(&year-1); %let yearm2=%eval(&year - 2); title "&pgm.: Create Final &year &period Base Tables Datasets"; libname acs&year "/pub/data/acs&year"; *<====; libname temp '/pub/data/temp'; libname basetbls "/pub/data/acs&year/basetbls"; options compress=binary; /* ========================begin comment==================================== proc sort data=acs2008.allgeos3yr force; by geoid; run; ==========================end comment====================================== */ ==> create_basetbls.sas <== x cd /pub/data/acs2008/Tools; %let pgm=create_basetbls; filename pgm "&pgm..sas"; *---This job was only used to process the single-year data for 2008. We coded a separate create_basetbls3yr.sas setup 5-7-10 to do similar processing of the 3yr data. We eventually want to modify and rerun this setup so that the geographic variables are also kept on the moe datasets as well, making it easier for users to run parallel extracts. jgb, 5-7-10---; *---The base tables data sets are mostly created by Billy Earny on the new platform and are copied to the P: drive from which they are uploaded and stored in the temp directory. The allgeos data set also is stored there and is converted to the final copy by the create_allgeos setup in this program library. In this setup we create the final, permanent basetbls datasets by merging and renaming the ustabs datasets in temp with the final allgeos dataset. To summarize the process of creating the acs2008\basetbls data sets: 1. bce downloads the raw data from CB web site. These get converted to mysql and then to sas datasets. These are then copied to the P: drive (\mcdc\acs2008\basetbls ). These have the basic data but need work regarding some naming conventions and the addition of standard geographic data. 2. The state level geographic data files are processed by bce to create an allgeos dataset which is also copied to the P: drive, basetbls folder. 3. Setup upload_edit_basetbls.sas is created (in the above basetbls directory on P:) and is run to upload the basetbls datasets to /pub/data/temp on this AIX site. We also upload a copy of that sas program file to this (Tools) directory. 4. We run the create_allgeos.sas setup here to access the uploaded temp.allgeos dataset and do final enhancements to it, creating acs2008.allgeos dataset. 5. This job creates the ustabsXXXXX datasets in /pub/data/acs2008/basetbls by merging the temp.ustabsXXXX datasets with the acs2008.allgeos dataset. Following this job you need to run 6. Run create_basetbls_metadata08.sas to create the variablesxxxx data sets and the Varlabs .txt files. We expect to repeat this cylce for the 3-yr period data when it becomes available. jgb, 9-30-09 ---*; %let period=3yr; %let subdir=%str(3yr/); %let period=%str(); %let subdir=%str(1yr/); %let year=2008; %let yr=%substr(&year,3,2); %let yearm1=%eval(&year-1); title "&pgm.: Create Final &year &period Base Tables Datasets"; libname acs&year "/pub/data/acs&year"; *<====; libname temp '/pub/data/temp'; libname basetbls "/pub/data/acs&year/basetbls"; options compress=binary; *<==================================Check to see of the temp datasets have the same names for current data*******************; %macro dotabs(tbls); data basetbls.ustabs&tbls&period(index=(geoid)); merge acs&year..allgeos(in=ingeos keep=SumLev--LogRecno) temp.ustabs&tbls._estimates(in=indata keep=geoid _numeric_ rename=(logrecno=_logrecnock)); by geoid; if not (ingeos and indata) or logrecno ne _logrecnock then do; put '****We have a problem with the merge: data is missing or inconsistent*** ' geoid= areaname= ingeos= indata= logrecno= _logrecnock= ; ==> invoke_dosets_profiles.sas <== x cd /pub/data/acs2008/Tools; %let pgm=invoke_dosets_profiles; filename pgm "&pgm..sas"; /*--Invoke the %doset macro to create observations in the Datasets dataset for the acs2008 directory which contains key profiles data sets as well as geography sets. Does not include basetbls data which is handled separately. J. Blodgett, OSEDA, Sept, 2009 -- */ title "Job to Invoke doset Macro for Sets in acs2008"; libname acs2008 '/pub/data/acs2008'; libname user '/tmp/scratch/user'; %let libnameg=acs2008; %let gyear=2008; *-----Run this step ONLY ONCE------------------------------------------; *----If you need to rerun (start over) then delete the datasets dataset first. doset will not allow initialize mode if the datasets set already exists.---; %***doset(mode=initialize, libname=acs2008,debug=1); *----------------------------------------------------------------------; options mprint; %doset(memname=_template_mcdcpros1, filetype=acs2008, geouniv=United States, memlabel=%str(MCDC profile extract for all US areas with 65,000+ population based on ~gyear surveys), Description=%nrbquote(MCDC-defined profile extracts for Areas of 65,000+ population as used in acsprofiles web app), units=%nrbquote(Nation State County PUMA etc), Year=&gyear, CreatePgm=upload_edit_usmcdcprofiles, keyvars=sumlev geocomp state county cbsa ua placefp metrodiv csa necta, keyfmats=sumlev geocomp state county cbsa uauc2k fplace metrodiv csa necta, keyquals= %str( | | | | | | state | | |), DataSource=%str(U.S. Bureau of the Census), SortedBy=State LogRecno, UsageNotes=%nrbquote(
  • These are 1-year estimates based on ACS data collected in ~gyear .
  • This dataset was created on a different system and copied to the archive.
  • Look for corresponding data set with "3yr" or "5yr" suffix to get similar data for multi-year periods.
  • Variables are about 90 pct based directly upon items in Census Bureau profile tables. But some we derived from reading the base tables. See Variables.pdf file in this directory for summary report.
  • Specify a filter of State Equal To 29 to select Missouri summaries only. Change 29 to 06 to select California data, etc.
  • Expect some missing values due to the Bureau policy not to release tables deemed statistically unreliable.
  • MOE (Margin of [sampling] Error) data are stored here along with the estimates. They all have names of form <estname>_moe
  • Standard geographic header info from Bureau geo txt files included.
), SubType=1yrpro, SetGroup=us, VarSet=variables, URLMeta=%str(http://mcdc2.missouri.edu/data/acs2008/Variables.pdf) ); ==> upload_edit_basetbls3yr.sas <== %let path=%str(p:\mcdc\acs2008_3yr\basetbls); %let pgm=upload_edit_basetbls3yr; filename pgm "&path\&pgm..sas"; x cd &path; *---Being run 11-18-09 to process 3-year period estimate base tables downloaded by bce----; libname acs2008 "&path"; filename rlink clear; filename rlink 'c:\tcpunix2.scr'; signon mcdc; rsubmit; **libname temp '/pub/data/temp'; libname basetbls '/pub/data/acs2008/basetbls'; filename pgmaix '/pub/data/acs2008/Tools/upload_edit_basetbls3yr.sas'; options compress=binary; %macro doit(topics); *<==== Earlier run uploaded all the estimates datasets. Now we need to just do the moes sets--; **proc upload data=acs2008.ustabs&topics._estimates out=basetbls.ustabs&topics.3yr status=no; proc upload data=acs2008.ustabs&topics._moes out=basetbls.ustabs&topics._moes3yr status=no; run; %mend doit; options mprint; %doit(00_07) %doit(08) %doit(09_16) %doit(17_20) %doit(21_24) %doit(25_27) proc upload infile=pgm outfile=pgmaix status=no; run; *<---upload this program file---; endrsubmit; %put ****all done*****; ==> upload_edit_basetbls.sas <== %let path=%str(p:\mcdc\acs2008\basetbls); %let pgm=upload_edit_basetbls; filename pgm "&path\&pgm..sas"; x cd &path; *---Being rerun 9-29-09 after the economic tables data updated and final base tables downloaded by bce----; libname acs2008 "&path"; filename rlink clear; filename rlink 'c:\tcpunix2.scr'; signon mcdc; data acs2008.ustabs25_27_estimates; merge acs2008.ustabs25_26_estimates acs2008.ustabs27_estimates; by geoid; run; data acs2008.ustabs25_27_moes; merge acs2008.ustabs25_26_moes acs2008.ustabs27_moes; by geoid; run; rsubmit; libname temp '/pub/data/temp'; libname basetbls '/pub/data/acs2008/basetbls'; ***libname lastyrs '/pub/data/acs2007/basetbls'; *<---previous years data---; filename pgmaix '/pub/data/acs2008/Tools/upload_edit_basetbls.sas'; options compress=binary; proc upload inlib=acs2008 outlib=temp status=no; exclude ustabs25_26_estimates ustabs27_estimates ustabs25_26_moes ustabs27_moes; run; proc upload infile=pgm outfile=pgmaix status=no; run; *<---upload this program file---; endrsubmit; %put ****all done*****; ==> upload_edit_usmcdcprofiles3yr.sas <== %let path=%str(p:\mcdc\acs2008_3yr); %let pgm=upload_edit_usmcdcprofiles3yr; filename pgm "&path\&pgm..sas"; x cd &path; *---Being coded and run 11-3-09. Creates datasets acs2008.usmcdcprofiles3yr and acs2008.allgeos3yr ----*; *---Submitted from Windows but most of the work is done on Unix via a rsubmit block. This pgm file is saved in Tools; libname acs2008 "&path"; filename rlink clear; filename rlink 'c:\tcpunix2.scr'; signon mcdc; options ls=132; rsubmit; options ls=132; libname temp '/pub/data/temp'; libname aix2008 '/pub/data/acs2008'; libname acs2007 '/pub/data/acs2007'; *<---previous years data---; filename pgmaix '/pub/data/acs2008/Tools/upload_edit_usmcdcprofiles3yr.sas'; proc upload infile=pgm outfile=pgmaix status=no; run; *<---upload this program file---; /* =======================Comment out. Already ran========================================== proc upload data=acs2008.usmcdcprofiles out=temp.usmcdcprofiles3yr status=no; run; proc upload data=acs2008.allgeos out=temp.allgeos3yr status=no; run; ======================End comment======================================================= */ data aix2008.usmcdcprofiles3yr(label='MCDC profile extract for all US areas with 205,000+ population based on 2006-2008 surveys' compress=Yes); if 0 then set aix2008.usmcdcprofiles(drop=datecreated); *--this sets up the program data vector, establishing the variable order with lengths, labels and formats----; set temp.usmcdcprofiles3yr; *---this puts the data into the pdv slots.----; *** DateCreated=today(); Years='2006-2008'; period='3yr'; Geocomp_name=put(geocomp,$geocomp.); if sumlev='795' then do; length PUMA $5; puma=substr(geoid,10,5); if state='29' then Areaname=put(puma,$mopuma.); end; if sumlev='160' then placefp=substr(geoid,10,5); run; %let period=3yr; %let year=2008; libname georef '/pub/data/georef' access=readonly; *-----This step adapted from the cnvt_geo_files.sas setup used to read the geogrpahic header txt files directly with 2007 data. But now we are using a set stmt to access the dataset created by bce on windows as the data source. We have to do some renaming, reformatting and re-ordering of variables to remain consistent.-----; data aix2008.allgeos3yr(label='Geographic ID data for the 3-year period estimates' compress=Yes); length SumLev $3 geoid $20 geocode $12 Name $120 AreaName $100 Geocomp_Name $64 State Stab $2 Geocomp $2 LogRecno 8 County $5 CBSA $5 cbsaType $5 UA $5 PlaceFP $5 PUMA5 $5 sdelm sdsec sduni $5 Region Division $1 CongDist $2 MetroDiv $5 CSA $3 NECTA $5 ; label sumlev=' ' geoid=' ' areaname=' ' state=' ' geocomp=' ' logrecno=' ' county=' ' cbsa=' ' ua=' ' placefp=' ' puma5=' ' name=' '; ==> upload_edit_usmcdcprofiles.sas <== %let path=%str(p:\mcdc\acs2008); %let pgm=upload_edit_usmcdcprofiles; filename pgm "&path\&pgm..sas"; x cd &path; *---Being rerun 9-29-09 after the economic tables data updated----; libname acs2008 "&path"; filename rlink clear; filename rlink 'c:\tcpunix2.scr'; signon mcdc; rsubmit; libname temp '/pub/data/temp'; libname aix2008 '/pub/data/acs2008'; libname acs2007 '/pub/data/acs2007'; *<---previous years data---; filename pgmaix '/pub/data/acs2008/Tools/upload_edit_usmcdcprofiles.sas'; proc upload data=acs2008.usmcdcprofiles_2008 out=temp.usmcdcprofiles status=no; run; proc upload infile=pgm outfile=pgmaix status=no; run; *<---upload this program file---; *data temp.usmcdcprofiles; *--get rid of formats and informat specs on all numeric vars--; * set temp.usmcdcprofiles; * format _numeric_ ; * informat _numeric_ ; * informat _character_ ; * run; data aix2008.usmcdcprofiles(label='MCDC profile extract for all US areas with 65,000+ population based on 2008 surveys'); if 0 then set acs2007.usmcdcprofiles(drop=datecreated); *--this sets up the program data vector, establishing the variable order with lengths, labels and formats----; set temp.usmcdcprofiles; *---this puts the data into the pdv slots.----; *** DateCreated=today(); Years='2008'; period='1yr'; Geocomp_name=put(geocomp,$geocomp.); if sumlev='795' then do; length PUMA $5; puma=substr(geoid,10,5); if state='29' then Areaname=put(puma,$mopuma.); end; if sumlev='160' then placefp=substr(geoid,10,5); run; proc print data=aix2008.usmcdcprofiles(keep=_character_ totpop obs=100); title2 "First 100 Obs on acs2008.usmcdcprofile"; run; endrsubmit; %put ****all done*****; ==> variables_report.sas <== x cd /pub/data/acs2008/Tools; %let pgm=variables_report; filename pgm "&pgm..sas"; /*--Using the uploaded variables dataset generate the Variables.pdf report file. bce already created a Variables.html file so call ours Variables2.html (for now). THIS SETUP DOES NOT WORK SINCE THE VARIABLES DATA SET CREATED BY BCE IS NOT COMPATIBLE WITH WHAT WE EXPECT jgb, 10-1-09. ---*/ libname acs2008 '/pub/data/acs2008'; options nonumber nodate orientation=landscape nocenter; ods printer pdf file="../Variables.pdf" ; ****orient=landscape; ods html file="../Variables2.html" contents="../VariablesContent.html" style=osedablue; ods listing close; proc print data=acs2008.Variables label; where pctflag=0 or UnivVar=' '; *<--do not show the Pct variables unless they are stand-alone--; by table notsorted universe notsorted; id name; var label--comment UnivVar WtVar; format label $char.; title 'Metadata for the acs2008 profiles (Partial listing of Variables dataset)'; footnote 'Note: Universe Variable is denominator used to create corresponding Pct Variable'; title2 "Revised as of &sysdate &systime"; run; ods printer close; ods html close; %include sascode(notify); ==> wic_eligible_tots.sas <== x cd /pub/data/acs2008/Tools; %let pgm=wic_eligible_tots; filename pgm "&pgm..sas"; *----Apply a CPR-like algorithm using data from detailed table b17024 (age by poverty ratio) to get estimate counts by Mo counties of persons aged 0-4 who are below 185% of the poverty level. For the Mo Hunger Atlas folks, Jill Lucht contact person. (The 185% of p.r. makes them WIC eligible and being aged 0-4 makes them tots. Hence the pgm name. ) J. Blodgett. 4/2010. ----*; %let acsyear=2008; *<---the acs vintage data year. The 2008 vintage data were released in 2009 and as of early 2010 are still the most current estimates.----; %let acsyr=%substr(&acsyear,3,2); %let acsyearm2=%eval(&Acsyear-2); %let acsyrm2=%substr(&acsyearm2,3,2); %let years=%str(&acsyearm2.-&acsyear); %libname(acspums); libname acsbtabs "/pub/data/acs&acsyear./basetbls"; %libname(acs2008); libname corrlst "/pub/data/corrlst"; libname cprdata "/pub/data/acs&acsyear./cprdata"; libname user '/tmp/scratch/userb'; *----Step 1: Access the PUMS data to get fudge factors at state and PUMA level. We use these factors to convert data for 0-5, <=185 to 0-4, <=185 for the state and use it to adjust data for counties with acs data. We also calculate the percent of persons 0-4 who are <= 185 by PUMA and we shall apply those ratios to the latest county pop estimates by age to get estimated <=185 for tots data. ----; /* ========================begin comment==================================== data aggin; set acspums.moprecs083yr(keep=agep povpip pwgtp puma ); where agep <=5; *---Keep only records for persons age 0-5---; if agep <=4 then do; age0_4=pwgtp; if povpip<=185 then Age0_4Under185=pwgtp; else Age0_4Under185=0; end; else age0_4=0; age0_5=pwgtp; if povpip<=185 then Age0_5Under185=pwgtp; else Age0_5Under185=0; drop agep povpip pwgtp; run; proc summary data=aggin; class puma; var _numeric_; output out=aggout sum=; run; data fudgefacts_wic(label='From wic_eligible_tots'); set aggout; if _type_=0 then do; *---Statewide. We use a fudge factor called F2 that we shall apply to all counties that have a table b17024. It is used to "factor down" the 0-5 poor tots to get just 0-4 poor tots. It is a simple ratio, calculated as follows.... ; F2=Age0_4Under185/Age0_5Under185; format f2 5.3;