x cd /pub/data/sf32000x/Tools; %let pgm=xxtrbgs; filename pgm "&pgm..sas"; /*----------------------------------------------------------------------------------------------------------------- Create the standard extract sf3 datasets for the collection of state-level trbgs datasets (complete tract and bgs). Coded by John Blodgett, OSEDA, U. of Missouri, blodgettj@umsystem.edu Under contract with the Missouri Census Data Center Revision History: Sept, 2008: Coding begins. Adding test steps to try and get a handle on why it takes way too long to access the input data set. Rerun 11-20-09 after fix to var defns. Rerunning 6-21-10 after finding problem with trunactated datsets for NC. ------------------------------------------------------------------------------------------------------*/ libname sf3 '/pub/data/sf32000/xxtrbgs' access=readonly; libname sf3x '/pub/data/sf32000x/xxtrbgs'; *** options msglevel=i fullstimer; *** proc options; run; *---This is a time-test step to see how long it takes to read the data---; ***data test; *** set sf3.motrbgsph(OBS=200); *** run; title "Create tracts and bg sf3x datasets for entire US"; %let dvmode=data; *--required by dovar macro which is invoked dozens of times by the invoke_dovars module--; title "&pgm: Create sf32000x Extract Datasets from sf32000 Datasets"; *----the dovar macro is where the work is actually done. Below, the included invoke_dovars.sas serves as the "driver" which invokes this macro once per variable. ---; options NOmprint; %macro doit(state,stab); data _null_; ct=time(); file stdout; put "Start conversion of &state &stab at &systime ."; run; %let setin=&stab.trbgsph; *---------Here is the (1st) conversion data step-------------*; data sf3x.&stab.tracts (label="&statenm Census Tract Summaries") sf3x.&stab.bgs (label="&statenm Block Group Summaries") ; length default=5 Logrecno 5 SumLev $3 esriid $12 Tract $7 BG $1 Areaname Geocode $16 ; retain State "&state" stab "&stab"; set sf3.&setin end=_last; Obs+1; by county tract; length _edtractn 8 _edtractc $7; if first.tract then do; _edtractn=tract; _edtractc=put(_edtractn,7.2); if substr(_edtractc,5,3)='.00' then substr(_edtractc,5)=' '; _edtractc=left(_edtractc); end; retain _edtractc; if sumlev='140' then Areaname="Tract "||tract; else Areaname="BG "||bg||", Tract "||_edtractc; %include 'invoke_dovars.sas'/NOsource2; if Sumlev='140' then output sf3x.&stab.tracts; else output sf3x.&stab.bgs; keep sumlev state stab county tract bg AreaName Geocode IntptLat IntPtLon LandSQMI AreaSQMI esriid Logrecno; keep msacmsa pmsa necma cbsa07 cbsaname; *<----added to list of keep vars 7-21-10, jgb---; keep TotPop -- AvgHValue; drop pct19i: pct8i3; label Obs='Obs #'; run; proc means data=sf3x.&stab.tracts(keep=sumlev totpop) n sum maxdec=0; class sumlev; var totpop; title2 "Check Sums by Sumlev on sf3x.&stab.tracts dataset"; run; proc means data=sf3x.&stab.bgs(keep=sumlev totpop) n sum maxdec=0; class sumlev; var totpop; title2 "Check Sums by Sumlev on sf3x.&stab.bgs dataset"; run; %mend doit; %***dostates(01 10,names=1,msgs=1); *<----test run, Delaware. --; %dostates(01 02 04 05 06 08 09 10,names=1,msgs=1); %dostates(11 12 13 15 16 17 18 19 20 21 22 23 24 25); %dostates(26 27 28,names=1,msgs=1); %dostates(29 30 31 32 33 34 35 36 37,names=1,msgs=1); %dostates(38 39 40 41 42 44 45 46 47 48 49 50 51 53 54 55 56,names=1,msgs=1); %**dostates(09 23 25);