x cd /pub/data/acs2012/Tools; %let pgm=cnvt_table_number_lookup; filename pgm "&pgm..sas"; *---the SAS data set we downloaded from the FTP site could not be read (Windows format?). So we create our own by reading the corresponding txt file. Then from their data set we create our own tables1 and datacells1 metadata sets. jgb, 9/13. ---*; %let datadir=%str(/pub/data/acs2012/basetbls); libname btabs12 "&datadir"; filename txtin "&datadir./Sequence_Number_and_Table_Number_Lookup.txt"; x cd /pub/data/acs2012/Tools; %let pgm=cnvt_table_number_lookup; filename pgm "&pgm..sas"; *---the SAS data set we downloaded from the FTP site could not be read (Windows format?). So we create our own by reading the corresponding txt file. Then from their data set we create our own tables1 and datacells1 metadata sets. jgb, 9/13. ---*; %let datadir=%str(/pub/data/acs2012/basetbls); libname btabs12 "&datadir"; filename txtin "&datadir./Sequence_Number_and_Table_Number_Lookup.txt"; /* ========================begin comment==================================== ==========================end comment====================================== */ data btabs12.seqtab1(label="2012 vintage 1-year tables metadata" compress=yes); infile txtin lrecl=1000 dsd missover firstobs=2; length fileid $5 tblid $12 SeqNum 4 position 4 StartPos 4 _cells $10 CellsinSeq 4 title $200 subject_area $100; length Cells 4 Type $8; *--we assign this code to help us ID the type of metadata contained in the line/obs-; length Topic $2 TopicGrp $5 BC $1 tblidbase $6 TableNo $5 TblSfx $2 IndentLvl 3; retain Topic--TblSfx IndentLvl; input fileid--subject_area; if fileid='ACSSF'; if tblid ne lag(tblid) then do; IndentLvl=0; _lastLineEnded='-'; Topic=substr(tblid,2,2); TableNo=substr(tblid,2,5); label TableNo='Numeric part of tblid'; if Topic le '07' then TopicGrp='00_07'; else if Topic='08' then TopicGrp='08'; else if Topic le '16' then TopicGrp='09_16'; else if Topic le '20' then TopicGrp='17_20'; else if Topic le '24' then TopicGrp='21_24'; else TopicGrp='25_27'; BC=substr(tblid,1,1); *--B or C table--; tblidbase=substr(tblid,1,6); tblsfx=substr(tblid,7); end; if index(_cells,'CELL') then do; cells=scan(_cells,1); type='TITLE'; end; else if title=:'Universe' then type='UNIVERSE'; else if position then do; type='DATALINE'; end; else type='OTHER'; retain _lastlineEnded ' ' _thislineEnds ' '; if type='DATALINE' then do; _thislineEnds=substr(title,length(title),1); if _lastlineEnded=':' then IndentLvl+1; if _thislineEnds=':' and _lastLineEnded ne ':' and IndentLvl>0 then IndentLvl=IndentLvl-1; _lastlineEnded=_thislineEnds; end; drop fileid _: _: ; label seqnum='Input file #' CellsinSeq='# cells in seqnum' position='Cell #' StartPos='Position on input file' ; label TableNo='5-digit Table #' BC='B or C (table type)' tblidbase='Table ID wo Suffix' tblsfx='Tab R suffix or PR' IndentLvl='Indent Level for display' ; run; proc sort; by tableno bc tblsfx position; run; proc print data=btabs12.seqtab1(obs=100); by tblid; id tblid; run; ods output close; ods html file="&pgm..html" ; data btabs12.tables1(label='1-year Table Summary Data'); set btabs12.seqtab1; where type in ('TITLE','UNIVERSE') ; by tableno bc tblsfx; retain; length TableTitle $200 Universe $100 AlphaSfxs $10; **** Topic $2 TopicGrp $5 BC $1 TableNo $5 AlphaSfxs $10 ; length ncellsAlpha 4; label ncellsAlpha='# cells in alpha-suffix tables'; if first.bc then do; TableID=tblid; if tblsfx=' ' then Alphasfxs='_'; else do; TableID=tblidbase; Alphasfxs=' '; end; TableTitle=translate(title,'`',"'"); *--Replace quotes with pseduo-quotes--; Ncells=cells; NcellsAlpha=0; nsfxs=0; Universe=' '; end; else if type='TITLE' and tblsfx ne ' ' then do; ncellsAlpha=cells; *--added 11-25-14 after we discovered that the alpha-suffix tables could be shorter than non-alpha table-; end; else if type='UNIVERSE' then do; if Universe=' ' then Universe=title; if tblsfx ne ' ' then do; nsfxs+1; Alphasfxs=trimn(alphasfxs)||tblsfx; end; if last.bc then do; if nsfxs=0 then alphasfxs=' '; output; end; end; label Alphasfxs='Alpha suffixes (A,B,..,I, PR) available for this table'; label nsfxs='# suffix versions of table' TableID='Table ID wo Sfx' Ncells='# cell in table'; keep TableID TableTitle Universe Ncells NcellsAlpha Topic TopicGrp BC TableNo nsfxs Alphasfxs; run; proc print data=btabs12.tables1; by TopicGrp Topic; id tableid; title "btabs12.tables1"; run; ods html close;