x cd /pub/data/acs2005/Tools; %let pgm=basetables_metadata; filename pgm "&pgm..sas"; /*--Combine the different wave metadata sets to create the complete basetables and basetablevars metadata sets. J. Blodgett, OSEDA, Oct., 2006 -- Waves 1-3 Rev. 3/07 to add new variables table_type and table_topic to basetables. Drop comment. Rev, 3-6-07 to correct tableno, and add table_sfx and table_set vars. 5-2-07 to correct table_set values. -- */ title "Job to Create acs2005.basetables and acs2005.basetablevars"; libname user '/SAS_temp/user'; libname acs2005 '/pub/data/acs2005'; libname basetabs '/pub/data/acs2005/basetabs'; /* =======================Begin comment================ data basetabs_obs; set sashelp.vtable(keep=libname memname memlabel nobs nvar ) ; where libname='BASETABS' and not (memname =: 'DATASETS'); rename nvar=nvars memname=table_id; drop libname ; run; ======================End comment================== */ proc format; value $tabtop 01 = Age and Sex 02 = Race 03 = Hispanic or Latino Origin 04 = Ancestry 05 = 'Foreign Born; Citizenship' 06 = Place of Birth 07 = 'Residence Last Year; Migration' 08 = 'Journey to Work; Workers Characteristics' 09 = 'Children; Relationship' 10 = 'Grandparents; Age of household members' 11 = 'Households; Families' 12 = Marital status 13 = Fertility 14 = School enrollment 15 = Educational attainment 16 = Language spoken at home 17 = Poverty 18 = Disability 19 = 'Income (Households and families)' 20 = 'Earnings (Individuals)' 21 = Veteran status 22 = 'Transfer Programs; Food Stamps' 23 = Employment status 24 = 'Industry; Occupation; Class of Worker' 25 = 'Housing (Financial and Physical Characteristics)' 99 = Imputation table ; run; data btabs; length Table_ID $10 Wave $1 Table_Title $256 Table_Universe $208 Table_Topic $48 Nlines 4 ; format table_id $10. ; informat table_id $12.; length table_type $2 tableno 4 Table_sfx $3; format tableno z5.; set acs2005.tables (in=in1) acs2005.tables2 acs2005.tables3; if in1 then Wave='1'; *---Assign our own "table_type" code that identifies the primary kind of info stored in the table.---; if index(table_id,'PR') then table_type='PR'; else if substr(table_id,2,2)='99' then table_type='IM'; else table_type=substr(table_id,1,1); tableno=compress(substr(table_id,2),'ABCDEFGHIJKLMNOPQRSTUVWXYZ'); *--removes any alpha suffixes--; length _first2 $2; _first2=substr(table_id,2,2); table_topic=put(_first2,$tabtop.); if substr(Table_Id,2,2) ne '99' then table_sfx=substr(Table_id,7); *--1-char alpha code follows 1-char type & 5-digiti # on normal tables. Suffixes never used for IM tables ---; run; proc sort; by table_id; run; data acs2005.basetables(label='Metadata for all Base Tables, Waves 1 to 3'); length Table_ID $10 Table_Title $256 Table_Set $8; merge btabs basetabs_obs; by table_id; if substr(table_type,1,1) in ('B','C') then do; if nobs lt 2000 then table_type='SP'; else if nobs=2497 then table_type='PW'; end; if table_title ne memlabel then do; put / table_ID= wave= memlabel= table_title=; _nbad+1; if _nbad ge 20 then abort abend; end; if table_type in ('B','C') then Table_Set=trim(lowcase(table_type))||'tables'||wave; else Table_Set=lowcase(table_type)||'tables'; *---In the combine_base_tables2.sas setup we write the data for a base table to one of the datasets specified by Table_Set; drop _: memlabel; run; proc sort data=acs2005.basetables; by Table_Set Table_Type Wave table_ID; run; proc freq data=acs2005.basetables; table nobs Table_type Table_Sfx Table_Set; table (table_type table_topic)*wave; title2 'Freqs on acs2005.basetables'; run; ods listing close; options ls=157 ps=60; ods pdf file="/pub/data/acs2005/basetables.pdf" title="Base Tables Summary Report" style=sasweb; title "Listing of basetabs metadata Set Showing What Tables Go with Which acs2005 Datasets"; options nodate; proc print data=acs2005.Basetables label ; by Table_set Table_Type Wave ; id table_id; var Table_title Table_universe Table_topic Nlines nobs; label nobs='# Obs'; footnote .c=gray .h=1 "From setup in basetables_metadata.sas - Run &sysdate"; run;