x cd /pub/data/acs/Tools; %let pgm=invoke_dosets_btabs5yr; filename pgm "&pgm..sas";
/*--Invoke the %doset macro to create observations in the Datasets dataset for a directory such as
/pub/data/acsXXXX/btabs5yr , where XXXX is the acs vintage.
J. Blodgett, OSEDA, Mar, 2014.
Last revised: 3/17 to run with vintage 2015 5-year data. See companion setup invoke_dosets_basetbls.sas .
Because we segregate 5yr data into a separate subdirectory it needs to have its own Datasets.html page.
*********Be sure to run the commented out code to initialize the datasets dataset (mode=initialize)******
-- */
%let year=2014;
%let yearm4=%eval(&year - 4); %let years=%str(&yearm4.-&year);
title "Job to Invoke doset Macro for Sets in acs&year/btabs5yr, creating btabs5yr.datasets";
libname acs "/pub/data/acs&year";
libname btabs5yr "/pub/data/acs&year/btabs5yr";
%let libnameg=btabs5yr;
%let todolist=;
%let todo= ;
*-----Run this step ONLY ONCE------------------------------------------;
*----If you need to rerun (start over) then delete the datasets dataset first. doset will not
allow initialize mode if the datasets set already exists.---;
%***doset(mode=initialize,
libname=btabs5yr,debug=1);
*----------------------------------------------------------------------;
options mprint;
*--Create templates for the 6 basic estimates and moe datasets, a pair for each 1, 3 and 5-yr periods--*;
%doset(memname=_template_ustabs,
filetype=acs~year, libname=btabs5yr,
geouniv=%str(United States + PR),
units=%str(~units),
Years=%str(~years),
CreatePgm=ustabs5yr_basetabls,
Description=%nrbquote(Base tables for ~units for topic(s) ~topic_list . &years period estimates.),
DataSource=%str(U.S. Bureau of the Census),
SortedBy=State geoid,
UsageNotes=%nrbquote(
- Margin-of-error (MOE) values are here as well as the estimates. Estimate variables end with
the letter i and a cell #, and the corresponding MOE variables ends with the letter m and that cell #.
- With a few exceptions there are no population-size thresholds regarding these data. All geographic areas are reported.
- Unlike the 1 and 3-year base tables, there is virtually no data suppression within these tables.
- The actual data conversion for these data sets is done before the data arrive at this linux system. Our CreatePgm reference
is to a final processing run that handles merging complete geocodes and sorting/indexing the data sets.
- Variable-naming convention of table cells is MCDC standard. So what the Bureau doc calls B01001001,
we call B01001i1 (cell # is indicated by an "i" followed by the cell number without leading zeroes).
Change that i to an m and you have the corresponding MOE (margin of error) variable.
),
SubType=~topicgrp,
SetGroup=~units,
VarSet=,
URLMeta=%str(https://mcdc.missouri.edu/pub/data/acs&year/btabs5yr/Varlabs)
);
%macro doit(topicgrp,memuname,units);
data _null_;
length keyvars keyfmts keyquals $64;
retain tg "&topicgrp";
select(tg);
when('00_07') tl='Basic demographics and Ancestry';
when('08') tl='Journey to work';
when('09_16') tl='Households, Families, misc social characteristics';
when('17_20') tl='Income and Poverty';
when('21_24') tl='Employment, Veteran status and related items';
when('25_27') tl='Housing, Grp Qtrs and Insurance coverage';
end;
retain units "&units";
select(units);
when('bgs') do; keyvars='state county cbsa'; keyfmts='state county cbsa'; end;
when('tracts') do; keyvars='state county cbsa'; keyfmts='state county cbsa'; end;
when('cousubs') do; keyvars='state county cbsa'; keyfmts='state county cbsa'; end;
when('places') do; keyvars='state placefp'; keyfmts='$state $fplace'; keyquals='state'; end;
when('pumas') do; keyvars='state'; keyfmts='state'; end;
when('state county') do; keyvars='sumlev state county cbsa'; keyfmts='sumlev state county cbsa'; end;
when('zctas') do; keyvars='state'; keyfmts='state'; end;
end;
call symput('keyvarsparm',trim(keyvars));
call symput('keyfmatsparm',trim(keyfmts));
call symput('keyqualsparm',trim(keyquals));
call symput ('topic_list',trim(tl));
stop; run;
%if &units=bgs or &units=tracts %then %let create_program=bgtract5yr_basetbls; %else %let create_program=ustabs5yr_basetbls;
%put topicgrp=&topicgrp topic_list=&topic_list keyvarsparm=&keyvarsparm keyfmatsparm=&keyfmatsparm keyqualsparm=&keyqualsparm;
%put create_program=&create_program;
%doset(memname=us&memuname&topicgrp.,template=_template_ustabs, filetype=acs&year,
CreatePgm=&create_program ,
units=&units, years=%str(&years),
keyvars=&keyvarsparm,keyfmats=&keyfmatsparm,
memlabel=%str(&universe &units level base tables data for topic group &topicgrp),
%if %nrbquote(&keyqualsparm) ne %str() %then %do; keyquals=&keyqualsparm., %end;
debug=0);
%doset(memname=mo&memuname&topicgrp,template=us&memuname&topicgrp, filetype=acs&year,
universe=Missouri,description=%str(Missouri subset of us&memuname&topicgrp),
units=&units, years=%str(&years),
memlabel=%str(Missouri &memuname level base tables data for topic group &topicgrp),
debug=0);
%mend doit;
%doit(00_07,bgs,bgs) ;
%doit(00_07,tracts,tracts) ;
%doit(00_07,cousubs,cousubs) ;
%doit(00_07,places,places) ;
%doit(00_07,pumas,pumas) ;
%doit(00_07,stcnty,state county) ;
%doit(00_07,zctas,zctas) ;
%doit(08,bgs,bgs) ;
%doit(08,tracts,tracts) ;
%doit(08,cousubs,cousubs) ;
%doit(08,places,places) ;
%doit(08,pumas,pumas) ;
%doit(08,stcnty,state county) ;
%doit(08,zctas,zctas) ;
%doit(09_16,bgs,bgs) ;
%doit(09_16,tracts,tracts) ;
%doit(09_16,cousubs,cousubs) ;
%doit(09_16,places,places) ;
%doit(09_16,pumas,pumas) ;
%doit(09_16,stcnty,state county) ;
%doit(09_16,zctas,zctas) ;
%doit(17_20,bgs,bgs) ;
%doit(17_20,tracts,tracts) ;
%doit(17_20,cousubs,cousubs) ;
%doit(17_20,places,places) ;
%doit(17_20,pumas,pumas) ;
%doit(17_20,stcnty,state county) ;
%doit(17_20,zctas,zctas) ;
%doit(21_24,bgs,bgs) ;
%doit(21_24,tracts,tracts) ;
%doit(21_24,cousubs,cousubs) ;
%doit(21_24,places,places) ;
%doit(21_24,pumas,pumas) ;
%doit(21_24,stcnty,state county) ;
%doit(21_24,zctas,zctas) ;
%doit(25_27,bgs,bgs) ;
%doit(25_27,tracts,tracts) ;
%doit(25_27,cousubs,cousubs) ;
%doit(25_27,places,places) ;
%doit(25_27,pumas,pumas) ;
%doit(25_27,stcnty,state county) ;
%doit(25_27,zctas,zctas) ;
proc sort data=btabs5yr.datasets out=bysortprio; by sortprio; run;
proc print data=bysortprio;
by libname notsorted libpath ;
id memname;
var SortPrio SetGroup SubType VarSet URLmeta GeoUniv years ;
title2 'Listing of Selected Fields from nchsbri.datasets (Sorted by SortPrio)';
run ;
proc datasets library=btabs5yr nolist;
modify datasets;
index delete dataset memname;
index create dataset=(libname memname) / unique;
index create memname;
quit;
options mprint msglevel=i;
%gendshtm(libname=btabs5yr,debug=1,runprocc=0); *<=====Already ran proc contents=====;