x cd /pub/data/acs2011/Tools; %let pgm=test_invoke_dovarsbg; filename pgm "&pgm..sas"; *---Test new invoke_dovarsbg module to create extract datasets from basetbls datasets that can be used at the block group level, where we have limited tables. jgb, 11/12. ---*; %let period=5yr; %let vintage=2010; %let vintagem5=%eval(&vintage-5); %let year=&vintagem5 to &vintage; libname basetbls "/pub/data/acs&vintage./basetbls"; libname acs "/pub/data/acs&vintage."; libname user '/SAS_temp/user'; data merged1; merge basetbls.ustabs00_07&period(in=indata) /* basetbls.ustabs09_16&period basetbls.ustabs17_20&period basetbls.ustabs25_27&period */ acs.allgeos&period(in=ingeos); by geoid; if indata and ingeos; ***; where sumlev='010' and geocomp='00'; *<---specify geo subset---; run; %let dvmode=meta; %*--the "dovar mode" global parm controls what kind of output is generated by the dovar macro. The values are data or meta, which cause it to either generate actual conversion data step code or code to create metadata set Variables. The value is also looked at by smaller macros which generate the start and end of the data steps during which the dovar macro invocations take place. --*; title "&pgm: Create Block Group compatible profiles and profilevars datasets"; %global pctof table curtable curtabno dvmode display; %let curtabno=0; %let display=1; %let REFTABLES=; %macro cnvtmeta(mode); %global setin dvmode; %let setout=&setin; *--by default we use the input set name base as name of output set--; %let dvmode=&mode; %if &dvmode = %str(data) %then %do; *---------Here is the conversion data step-------------*; data acs.usmcdcprofiles. length default=5; * Obs 5 esriid $16; length years $12 period $3; set merged1; *label esriid='Id field to link to ESRI map files'; %if &period eq %then %do; Period="1yr"; %end; %else %do; Period="&period"; %end; Years="&year"; %end; %else %if &dvmode=%str(meta) %then %do; *------Here is the data step that generate sf3x.Variables when dvmode=meta-----------; data acs.VariablesBG(label="Meta data describing the variables on BG profiles datasets"); attrib Name label='Variable Name' length=$32 Label length=$80 format=$char. Definition length=$200 label='Definition - Code used to derive' Comment length=$400 Format length=$16 TypeLen length=$8 label='Variable type and length' Universe length=$64 UnivVar length=$32 label='Universe Variable' WtVar length=$32 label='Weight Variable' Lvl length=3 label="Data Indent Level" Display length=3 label="Display in std report?" PctFlag length=3 label='Pct Variable Flag' Table length=$80 TableNo length=3 label='Table #' Keywords length=$80 Year length=$4 Source length=$40 RefTables length=$40 label='Related Table(s)' ; retain Year "&vintage"; retain Source "&year ACS Summary Files, US Census Bureau'; %end; %else %put ***** dvmode parm value not recognized: value= &dvmode ; options NOmprint; %include 'invoke_dovarsbg.sas'; %*<----this module does the work of assigning the global parms and invoking the dovarsbg macro for each variable on the dataset. ; %if &dvmode=%str(data) %then %do; keep geoid areaname years state ; keep county cbsa metrodiv logrecno tract bg; keep TotPop -- DateCreated; drop _:; ***drop moe:; drop b0: b1: b2:; run; %end; %else %if &dvmode=%str(meta) %then %do; *-----meta processing-----------------------------; run; options nonumber nodate orientation=landscape nocenter; ods printer pdf file="../Variables.pdf" ; ****orient=landscape; ods html file="../Variables.html" contents="../VariablesContent.html" style=osedablue; ods listing close; proc print data=acs2007.Variables label; where pctflag=0 or UnivVar=' '; *<--do not show the Pct variables unless they are stand-alone--; by table notsorted universe notsorted; id name; var label--comment UnivVar WtVar; format label $char.; title 'Metadata for the acs2007 profiles (Partial listing of Variables dataset)'; footnote 'Note: Universe Variable is denominator used to create corresponding Pct Variable'; title2 "Revised as of &sysdate &systime"; run; ods printer close; ods html close; %end; %mend cnvtmeta; %cnvtmeta(meta) ; options nosource2; %cnvtmeta(data) ; run; /* proc datasets library=acs2007 nolist; modify usmcdcprofiles&period(read=budweisr); quit; */