x cd /pub/data/acs2011/Tools; %let pgm=tr5yr_basetbls; filename pgm "&pgm..sas"; *---Create the new and improved census tract level base tables data set. Merges data created by Glenn R. in the revised_basetbls temp subdirectory with the selected allgeos data set. A key is to specify shorter variables, with lengths of 4 instead of 8 bytes. Modeled after the bg5yr_basetbls setup which does the same for BGs. For now all we are doing are the complete tract 140-level data. May go back and do 080 later. jgb, 4-11-13. ---*; libname btabsR '/pub/data/acs2011/revised_basetbls' ; libname btabs5yr '/pub/data/acs2011/btabs5yr'; libname btabs '/pub/data/acs2011/basetbls'; %libname(acs2011); options compress=binary; %macro geofltr; *where also state in ('29'); where geoid=:'140'; %mend geofltr; data call_symputs(compress=no); set btabs.btabs5yrmeta; if lowcase(tgrp)='085yr' then tgrp='08'; macname="vars"||tgrp; call symput(macname,trim(vars)); moes=translate(vars,'m','e'); *--the corresponding MOE variable uses lower case m instead of e. So for estimate b00001e1 we have the corr moe as m00001m1 . --; macname="moes"||tgrp; call symput(macname,trim(moes)); run; %let idvars=SumLev AreaName esriid geoid state stab LogRecno County Logrecno CBSA cbsayr metdiv ; ** cousubfp placefp; data trids(compress=no); set acs2011.allgeos2007_2011(keep=&idvars rename=(logrecno=logrecnoN)); %geofltr ; length Logrecno $7; Logrecno=put(logrecnon,z7.); drop logrecnoN; run; proc sort; by state geoid; ** logrecno; run; %macro dotabs(tgroups=00_07 08 09_16 17_20 21_24 25_27); %let ng=1; %let tgroup=%scan(&tgroups,1); %do %until (&tgroup=%str()); data btabs5yr.ustracts&tgroup(label="U.S. complete tract level data for topic group &tgroup"); if 0 then set trids; *--to force these id variables to be first---; length Tract $7 ; length &&vars&tgroup &&moes&tgroup 4; *<-----controls length and order of these variables-; merge trids(in=ingeos keep=&idvars ) btabsR.ustracts&tgroup.5yr(in=inests keep=_character_ &&vars&tgroup) btabsR.ustracts&tgroup.5yr_moes(in=inmoes keep=_character_ &&moes&tgroup); by state geoid; %geofltr; esriid=substr(geoid,8); drop geoid; format county $5.; if not (ingeos and inests and inmoes) then do; _nerr+1; if _nerr le 20 then put / "**missing data** " ingeos= inests= inmoes= state= logrecno= geoid=; else abort abend; drop _nerr; end; tract=substr(esriid,6,4)||'.'||substr(esriid,10,2); *--to get our archive std xxxx.xx format code---; run; proc datasets nolist library=btabs5yr; modify ustracts&tgroup; index create state; index create county; quit; proc sql; create view btabs5yr.motracts&tgroup(label="MO subset of ustracts&tgroup") as select * from ustracts&tgroup where state='29'; quit; %let ng=%eval(&ng+1); %let tgroup=%scan(&tgroups,&ng); %end; %mend dotabs; options mprint; %dotabs(tgroups=00_07 08 09_16 17_20 21_24 25_27); %contdir(btabs5yr,dsn=btabs5yr);