x cd /pub/data/acs2011/Tools; %let pgm=us5yr_basetbls; filename pgm "&pgm..sas"; ******IN PROGRESS********************** ; ****NEVER RUN! See instead usbtabs5yr_basetbls.sas **************************************** *---Create the new and improved base tables data sets for larger geos (all but BGs and tracts). Merges data created by Glenn R. in the revised_basetbls temp subdirectory with the selected allgeos data set. Modeled after the tr5yr_basetbls setup which does the same for census tract summaries. jgb, 4-13-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; *here state in ('10','11'); *--Delaware and DC for test. Use same filter in step to create ids set above.--; *where state in ('29'); %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 state stab LogRecno County Logrecno CBSA cbsayr metdiv cousubfp placefp; data usallids(compress=no); set acs2011.allgeos2007_2011(keep=&idvars rename=(logrecno=logrecnoN)); %geofltr ; ****where sumlev in ('080','140'); length Logrecno $7; Logrecno=put(logrecnon,z7.); drop logrecnoN; run; proc sort; by state 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.ustabs&tgroup(label="U.S. data tables for topic group &tgroup"); if 0 then set usallids; *--to force these id variables to be first---; length &&vars&tgroup &&moes&tgroup 5; *<-----controls length and order of these variables-; merge usallids(in=ingeos keep=&idvars ) btabsR.ustabs&tgroup.5yr(in=inests keep=_character_ &&vars&tgroup) btabsR.ustabs&tgroup.5yr_moes(in=inmoes keep=_character_ &&moes&tgroup); by state logrecno; %geofltr; length esriid $24; 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; run; proc datasets nolist library=btabs5yr; modify ustabs&tgroup; index create state; index create sumlev; index create stslvl=(state sumlev); quit; proc sql; create view btabs5yr.motabs&tgroup(label="MO subset of ustabs&tgroup") as select * from ustabs&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);