x cd /pub/data/acs/Tools; %let pgm=detailed_tables_5yr; filename pgm "&pgm..sas"; *---Read the Bureau-provided spreadsheet (converted to CSV and downloaded from http://www.census.gov/acs/www/data_documentation/5_year_preview/ - the "Detailed Tables" link 11-8-10 (originally!) Save the edited and restrucutured data as acs.detailedtabs5yr . jgb, 11-8-10 ---*; *---We are rerunning this setup 11-17-10 after we noticed that the source xls file at the Census Bureau site was different than what we were seeing in the generated Varlabs/bgleveltabs.txt file. So we are regenerating. We have a new copy of the csvin file, which was created using a save-as from the bureaus xls file, same as before. We saved the old CSV input file, the acs data set and the output Varlabs txt files, renaming all with "Nov8" inserted in names. ---*; %let year=2009; %let btpath=%str(/pub/data/acs&year./basetbls); libname basetbls "&btpath"; filename csvin '../Docs/Tables2005_2009ACS5_YearEstimates.csv'; libname acs '/pub/data/acs'; data acs.detailedtabs5yr(label='Detailed Tables for 5-year Data as Previewed Nov 2010, rev 11-17'); infile csvin dsd truncover firstobs=8 termstr=crlf; length TableID $9 TableName $123 Topic $2; *** TableType $1 TableNo 4 TableRSfx $1; length inAFF BGLevel AlphaSfx OnlyinSF 4 PRtable 4 Footnote $1; label inAFF='Available in AFF' OnlyinSF='Only in SF' BGlevel='Available for BGs' Alphasfx='Table has Alpha Sfx' ; length _note1-_note3 $32; input TableID TableName _note1-_note3; if TableID=:'B98' then stop; *--do not care about the b98 and b99 tables---; Topic=substr(tableid,2,2); PRTable= index(tableid,'PR') >0 ; AlphaSfx= (length(tableid) in (7,9)); inaff=0; bglevel=0; if _note1 ne ' ' then Inaff=1; OnlyinSF= not Inaff; if _note1=:'See Note' then Footnote=scan(_note1,3,' '); else if _note2=:'See Note' then Footnote=scan(_note2,3,' '); else if _note2=:'Nation' then Footnote='4'; *---available only for nation and/or State---; if _note3 ne ' ' then bglevel=1; lenght bgflag $1; bgflag=_note3; drop _: ; run; options linesize=158; proc sort; by prtable ; run; title "acs.detailedtabs5yr: Preview of 5-Year Summary Tables"; proc tabulate data=acs.detailedtabs5yr; by prtable; class topic ; var inaff bglevel alphasfx onlyinsf; table all topic,(inaff onlyinsf bglevel alphasfx)*sum="# tables"*f=comma5.; run; proc print data=acs.detailedtabs5yr (where=(bglevel)) label n; by prtable topic; title2 'Tables Available at the BG Level'; id tableid; var tablename inaff footnote; format tablename $90.; run; data basetbls.variables; set basetbls.variables00_07 basetbls.variables08 basetbls.variables09_16 basetbls.variables17_20 basetbls.variables21_24 basetbls.variables25_27; proc sort; by tableid; run; proc sql; create table acs.bgtabs as select distinct tableid from acs.detailedtabs5yr where bglevel=1; quit; proc sort data=basetbls.variables out=variables; by tableid; run; *---Finally, we generate the custom txt file that documents the variables within the tables available at BG level---; filename varlabs "&btpath/Varlabs/bgleveltabs.txt"; data _null_; merge variables acs.bgtabs(in=inbgs) end=last; by tableID ; if inbgs; file varlabs; if _n_=1 then put 'LABEL '; if first.tableid then put / '/* ' TableID +(-1)'. ' TableName ' */' / '/* Universe: ' universe ' */' /; length qlabel $260; qlabel=quote(trim(label)); put @5 name "=" qlabel; if last then put ' ;'; run; *---run comparison to see what tables have been added or deleted from bg list---; *---this step revealed that only the set of C230002 tables were deleted. Otherwise, no change since Nov 8--; proc sql; create table acs.bgtabs as select distinct tableid from acs.detailedtabs5yr where bglevel=1; create table acs.bgtabsnov8 as select distinct tableid from acs.detailedtabs5yrnov8 where bglevel=1; quit; data _null_; merge acs.bgtabs(in=innow) acs.bgtabsnov8(in=inthen); by tableid; if not innow and inthen; if innow then status='Added '; else status='Deleted'; put tableid +1 status; run;